summaryrefslogtreecommitdiff
path: root/zebra/if_netlink.c
diff options
context:
space:
mode:
authorMark Stapp <mjs@voltanet.io>2018-09-12 14:59:57 -0400
committerDonald Sharp <sharpd@cumulusnetworks.com>2018-09-19 18:34:25 -0400
commit85a75f1e775be73178d1b292ec0866fb336ddf2a (patch)
tree1680b5d2f030740314940b0db721827394fe32f2 /zebra/if_netlink.c
parentea1c14f6801881b7d2e1b4035b8f085f6d663927 (diff)
zebra: Start abstraction of zebra_dplane_info for context passing
Reduce or eliminate use of global zebra_ns structs in a couple of netlink/kernel code paths, so that those paths can potentially be made asynch eventually. Signed-off-by: Mark Stapp <mjs@voltanet.io> Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'zebra/if_netlink.c')
-rw-r--r--zebra/if_netlink.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/zebra/if_netlink.c b/zebra/if_netlink.c
index 47a101e619..65d60d8448 100644
--- a/zebra/if_netlink.c
+++ b/zebra/if_netlink.c
@@ -698,8 +698,8 @@ static int netlink_interface(struct nlmsghdr *h, ns_id_t ns_id, int startup)
}
/* Request for specific interface or address information from the kernel */
-static int netlink_request_intf_addr(struct zebra_ns *zns, int family, int type,
- uint32_t filter_mask)
+static int netlink_request_intf_addr(struct nlsock *netlink_cmd, int family,
+ int type, uint32_t filter_mask)
{
struct {
struct nlmsghdr n;
@@ -717,57 +717,62 @@ static int netlink_request_intf_addr(struct zebra_ns *zns, int family, int type,
if (filter_mask)
addattr32(&req.n, sizeof(req), IFLA_EXT_MASK, filter_mask);
- return netlink_request(&zns->netlink_cmd, &req.n);
+ return netlink_request(netlink_cmd, &req.n);
}
/* Interface lookup by netlink socket. */
int interface_lookup_netlink(struct zebra_ns *zns)
{
int ret;
+ struct zebra_dplane_info dp_info;
+ struct nlsock *netlink_cmd = &zns->netlink_cmd;
+
+ /* Capture key info from ns struct */
+ zebra_dplane_info_from_zns(&dp_info, zns, true /*is_cmd*/);
/* Get interface information. */
- ret = netlink_request_intf_addr(zns, AF_PACKET, RTM_GETLINK, 0);
+ ret = netlink_request_intf_addr(netlink_cmd, AF_PACKET, RTM_GETLINK, 0);
if (ret < 0)
return ret;
- ret = netlink_parse_info(netlink_interface, &zns->netlink_cmd, zns, 0,
+ ret = netlink_parse_info(netlink_interface, netlink_cmd, &dp_info, 0,
1);
if (ret < 0)
return ret;
/* Get interface information - for bridge interfaces. */
- ret = netlink_request_intf_addr(zns, AF_BRIDGE, RTM_GETLINK,
+ ret = netlink_request_intf_addr(netlink_cmd, AF_BRIDGE, RTM_GETLINK,
RTEXT_FILTER_BRVLAN);
if (ret < 0)
return ret;
- ret = netlink_parse_info(netlink_interface, &zns->netlink_cmd, zns, 0,
+ ret = netlink_parse_info(netlink_interface, netlink_cmd, &dp_info, 0,
0);
if (ret < 0)
return ret;
/* Get interface information - for bridge interfaces. */
- ret = netlink_request_intf_addr(zns, AF_BRIDGE, RTM_GETLINK,
+ ret = netlink_request_intf_addr(netlink_cmd, AF_BRIDGE, RTM_GETLINK,
RTEXT_FILTER_BRVLAN);
if (ret < 0)
return ret;
- ret = netlink_parse_info(netlink_interface, &zns->netlink_cmd, zns, 0,
+ ret = netlink_parse_info(netlink_interface, netlink_cmd, &dp_info, 0,
0);
if (ret < 0)
return ret;
/* Get IPv4 address of the interfaces. */
- ret = netlink_request_intf_addr(zns, AF_INET, RTM_GETADDR, 0);
+ ret = netlink_request_intf_addr(netlink_cmd, AF_INET, RTM_GETADDR, 0);
if (ret < 0)
return ret;
- ret = netlink_parse_info(netlink_interface_addr, &zns->netlink_cmd, zns,
+ ret = netlink_parse_info(netlink_interface_addr, netlink_cmd, &dp_info,
0, 1);
if (ret < 0)
return ret;
/* Get IPv6 address of the interfaces. */
- ret = netlink_request_intf_addr(zns, AF_INET6, RTM_GETADDR, 0);
+ ret = netlink_request_intf_addr(netlink_cmd, AF_INET6, RTM_GETADDR, 0);
if (ret < 0)
return ret;
- ret = netlink_parse_info(netlink_interface_addr, &zns->netlink_cmd, zns,
+ ret = netlink_parse_info(netlink_interface_addr, netlink_cmd, &dp_info,
0, 1);
if (ret < 0)
return ret;