diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2023-08-03 17:19:42 +1000 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2023-08-04 01:25:20 +0200 |
commit | 257a6b0b7e76e17bdd6e107ae643db4466960654 (patch) | |
tree | 9733127babbc8cc8a5ef49c6a0332f76b3fd5238 /pasta.c | |
parent | eff3bcb24547e671e63df9b70157c3ff9bb9f95a (diff) | |
download | passt-257a6b0b7e76e17bdd6e107ae643db4466960654.tar passt-257a6b0b7e76e17bdd6e107ae643db4466960654.tar.gz passt-257a6b0b7e76e17bdd6e107ae643db4466960654.tar.bz2 passt-257a6b0b7e76e17bdd6e107ae643db4466960654.tar.lz passt-257a6b0b7e76e17bdd6e107ae643db4466960654.tar.xz passt-257a6b0b7e76e17bdd6e107ae643db4466960654.tar.zst passt-257a6b0b7e76e17bdd6e107ae643db4466960654.zip |
netlink: Split nl_route() into separate operation functions
nl_route() can perform 3 quite different operations based on the 'op'
parameter. Split this into separate functions for each one. This requires
more lines of code, but makes the internal logic of each operation much
easier to follow.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'pasta.c')
-rw-r--r-- | pasta.c | 16 |
1 files changed, 10 insertions, 6 deletions
@@ -281,8 +281,6 @@ void pasta_ns_conf(struct ctx *c) nl_link_set_mac(1, c->pasta_ifi, c->mac_guest); if (c->pasta_conf_ns) { - enum nl_op op_routes = c->no_copy_routes ? NL_SET : NL_DUP; - nl_link_up(1, c->pasta_ifi, c->mtu); if (c->ifi4) { @@ -293,8 +291,11 @@ void pasta_ns_conf(struct ctx *c) nl_addr_dup(c->ifi4, c->pasta_ifi, AF_INET); } - nl_route(op_routes, c->ifi4, c->pasta_ifi, AF_INET, - &c->ip4.gw); + if (c->no_copy_routes) + nl_route_set_def(c->pasta_ifi, AF_INET, + &c->ip4.gw); + else + nl_route_dup(c->ifi4, c->pasta_ifi, AF_INET); } if (c->ifi6) { @@ -305,8 +306,11 @@ void pasta_ns_conf(struct ctx *c) nl_addr_dup(c->ifi6, c->pasta_ifi, AF_INET6); } - nl_route(op_routes, c->ifi6, c->pasta_ifi, AF_INET6, - &c->ip6.gw); + if (c->no_copy_routes) + nl_route_set_def(c->pasta_ifi, AF_INET6, + &c->ip6.gw); + else + nl_route_dup(c->ifi6, c->pasta_ifi, AF_INET6); } } |