zebra: Remove unnecessary function parameter

The snl variable is no longer needed to be passed around, so
remove it from the calling path.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
Donald Sharp 2018-05-23 09:37:06 -04:00
parent 783827ae61
commit 2414abd3b0
8 changed files with 46 additions and 67 deletions

View File

@ -557,10 +557,11 @@ static int netlink_bridge_interface(struct nlmsghdr *h, int len, ns_id_t ns_id,
return 0; return 0;
} }
/* Called from interface_lookup_netlink(). This function is only used /*
during bootstrap. */ * Called from interface_lookup_netlink(). This function is only used
static int netlink_interface(struct sockaddr_nl *snl, struct nlmsghdr *h, * during bootstrap.
ns_id_t ns_id, int startup) */
static int netlink_interface(struct nlmsghdr *h, ns_id_t ns_id, int startup)
{ {
int len; int len;
struct ifinfomsg *ifi; struct ifinfomsg *ifi;
@ -874,8 +875,7 @@ int kernel_address_delete_ipv6(struct interface *ifp, struct connected *ifc)
return netlink_address(RTM_DELADDR, AF_INET6, ifp, ifc); return netlink_address(RTM_DELADDR, AF_INET6, ifp, ifc);
} }
int netlink_interface_addr(struct sockaddr_nl *snl, struct nlmsghdr *h, int netlink_interface_addr(struct nlmsghdr *h, ns_id_t ns_id, int startup)
ns_id_t ns_id, int startup)
{ {
int len; int len;
struct ifaddrmsg *ifa; struct ifaddrmsg *ifa;
@ -1078,8 +1078,7 @@ static void if_netlink_check_ifp_instance_consistency(uint16_t cmd,
*/ */
} }
int netlink_link_change(struct sockaddr_nl *snl, struct nlmsghdr *h, int netlink_link_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)
ns_id_t ns_id, int startup)
{ {
int len; int len;
struct ifinfomsg *ifi; struct ifinfomsg *ifi;

View File

@ -23,10 +23,9 @@
#ifdef HAVE_NETLINK #ifdef HAVE_NETLINK
extern int netlink_interface_addr(struct sockaddr_nl *snl, struct nlmsghdr *h, extern int netlink_interface_addr(struct nlmsghdr *h, ns_id_t ns_id,
ns_id_t ns_id, int startup); int startup);
extern int netlink_link_change(struct sockaddr_nl *snl, struct nlmsghdr *h, extern int netlink_link_change(struct nlmsghdr *h, ns_id_t ns_id, int startup);
ns_id_t ns_id, int startup);
extern int interface_lookup_netlink(struct zebra_ns *zns); extern int interface_lookup_netlink(struct zebra_ns *zns);
#endif /* HAVE_NETLINK */ #endif /* HAVE_NETLINK */

View File

@ -128,8 +128,7 @@ extern uint32_t nl_rcvbufsize;
extern struct zebra_privs_t zserv_privs; extern struct zebra_privs_t zserv_privs;
int netlink_talk_filter(struct sockaddr_nl *snl, struct nlmsghdr *h, int netlink_talk_filter(struct nlmsghdr *h, ns_id_t ns_id, int startup)
ns_id_t ns_id, int startup)
{ {
/* /*
* This is an error condition that must be handled during * This is an error condition that must be handled during
@ -244,8 +243,7 @@ static int netlink_socket(struct nlsock *nl, unsigned long groups,
return ret; return ret;
} }
static int netlink_information_fetch(struct sockaddr_nl *snl, static int netlink_information_fetch(struct nlmsghdr *h, ns_id_t ns_id,
struct nlmsghdr *h, ns_id_t ns_id,
int startup) int startup)
{ {
/* /*
@ -259,25 +257,25 @@ static int netlink_information_fetch(struct sockaddr_nl *snl,
*/ */
switch (h->nlmsg_type) { switch (h->nlmsg_type) {
case RTM_NEWROUTE: case RTM_NEWROUTE:
return netlink_route_change(snl, h, ns_id, startup); return netlink_route_change(h, ns_id, startup);
case RTM_DELROUTE: case RTM_DELROUTE:
return netlink_route_change(snl, h, ns_id, startup); return netlink_route_change(h, ns_id, startup);
case RTM_NEWLINK: case RTM_NEWLINK:
return netlink_link_change(snl, h, ns_id, startup); return netlink_link_change(h, ns_id, startup);
case RTM_DELLINK: case RTM_DELLINK:
return netlink_link_change(snl, h, ns_id, startup); return netlink_link_change(h, ns_id, startup);
case RTM_NEWADDR: case RTM_NEWADDR:
return netlink_interface_addr(snl, h, ns_id, startup); return netlink_interface_addr(h, ns_id, startup);
case RTM_DELADDR: case RTM_DELADDR:
return netlink_interface_addr(snl, h, ns_id, startup); return netlink_interface_addr(h, ns_id, startup);
case RTM_NEWNEIGH: case RTM_NEWNEIGH:
return netlink_neigh_change(snl, h, ns_id); return netlink_neigh_change(h, ns_id);
case RTM_DELNEIGH: case RTM_DELNEIGH:
return netlink_neigh_change(snl, h, ns_id); return netlink_neigh_change(h, ns_id);
case RTM_NEWRULE: case RTM_NEWRULE:
return netlink_rule_change(snl, h, ns_id, startup); return netlink_rule_change(h, ns_id, startup);
case RTM_DELRULE: case RTM_DELRULE:
return netlink_rule_change(snl, h, ns_id, startup); return netlink_rule_change(h, ns_id, startup);
default: default:
/* /*
* If we have received this message then * If we have received this message then
@ -512,8 +510,7 @@ const char *nl_rttype_to_str(uint8_t rttype)
* startup -> Are we reading in under startup conditions? passed to * startup -> Are we reading in under startup conditions? passed to
* the filter. * the filter.
*/ */
int netlink_parse_info(int (*filter)(struct sockaddr_nl *, struct nlmsghdr *, int netlink_parse_info(int (*filter)(struct nlmsghdr *, ns_id_t, int),
ns_id_t, int),
struct nlsock *nl, struct zebra_ns *zns, int count, struct nlsock *nl, struct zebra_ns *zns, int count,
int startup) int startup)
{ {
@ -691,7 +688,7 @@ int netlink_parse_info(int (*filter)(struct sockaddr_nl *, struct nlmsghdr *,
continue; continue;
} }
error = (*filter)(&snl, h, zns->ns_id, startup); error = (*filter)(h, zns->ns_id, startup);
if (error < 0) { if (error < 0) {
zlog_err("%s filter function error", nl->name); zlog_err("%s filter function error", nl->name);
ret = error; ret = error;
@ -725,8 +722,7 @@ int netlink_parse_info(int (*filter)(struct sockaddr_nl *, struct nlmsghdr *,
* startup -> Are we reading in under startup conditions * startup -> Are we reading in under startup conditions
* This is passed through eventually to filter. * This is passed through eventually to filter.
*/ */
int netlink_talk(int (*filter)(struct sockaddr_nl *, struct nlmsghdr *, ns_id_t, int netlink_talk(int (*filter)(struct nlmsghdr *, ns_id_t, int startup),
int startup),
struct nlmsghdr *n, struct nlsock *nl, struct zebra_ns *zns, struct nlmsghdr *n, struct nlsock *nl, struct zebra_ns *zns,
int startup) int startup)
{ {

View File

@ -45,14 +45,11 @@ extern const char *nl_rtproto_to_str(uint8_t rtproto);
extern const char *nl_family_to_str(uint8_t family); extern const char *nl_family_to_str(uint8_t family);
extern const char *nl_rttype_to_str(uint8_t rttype); extern const char *nl_rttype_to_str(uint8_t rttype);
extern int netlink_parse_info(int (*filter)(struct sockaddr_nl *, extern int netlink_parse_info(int (*filter)(struct nlmsghdr *, ns_id_t, int),
struct nlmsghdr *, ns_id_t, int),
struct nlsock *nl, struct zebra_ns *zns, struct nlsock *nl, struct zebra_ns *zns,
int count, int startup); int count, int startup);
extern int netlink_talk_filter(struct sockaddr_nl *, struct nlmsghdr *, ns_id_t, extern int netlink_talk_filter(struct nlmsghdr *h, ns_id_t ns, int startup);
int startup); extern int netlink_talk(int (*filter)(struct nlmsghdr *, ns_id_t, int startup),
extern int netlink_talk(int (*filter)(struct sockaddr_nl *, struct nlmsghdr *,
ns_id_t, int startup),
struct nlmsghdr *n, struct nlsock *nl, struct nlmsghdr *n, struct nlsock *nl,
struct zebra_ns *zns, int startup); struct zebra_ns *zns, int startup);
extern int netlink_request(struct nlsock *nl, struct nlmsghdr *n); extern int netlink_request(struct nlsock *nl, struct nlmsghdr *n);

View File

@ -246,8 +246,7 @@ static vrf_id_t vrf_lookup_by_table(uint32_t table_id, ns_id_t ns_id)
} }
/* Looking up routing table by netlink interface. */ /* Looking up routing table by netlink interface. */
static int netlink_route_change_read_unicast(struct sockaddr_nl *snl, static int netlink_route_change_read_unicast(struct nlmsghdr *h, ns_id_t ns_id,
struct nlmsghdr *h, ns_id_t ns_id,
int startup) int startup)
{ {
int len; int len;
@ -627,8 +626,7 @@ static int netlink_route_change_read_unicast(struct sockaddr_nl *snl,
static struct mcast_route_data *mroute = NULL; static struct mcast_route_data *mroute = NULL;
static int netlink_route_change_read_multicast(struct sockaddr_nl *snl, static int netlink_route_change_read_multicast(struct nlmsghdr *h,
struct nlmsghdr *h,
ns_id_t ns_id, int startup) ns_id_t ns_id, int startup)
{ {
int len; int len;
@ -717,8 +715,7 @@ static int netlink_route_change_read_multicast(struct sockaddr_nl *snl,
return 0; return 0;
} }
int netlink_route_change(struct sockaddr_nl *snl, struct nlmsghdr *h, int netlink_route_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)
ns_id_t ns_id, int startup)
{ {
int len; int len;
struct rtmsg *rtm; struct rtmsg *rtm;
@ -749,9 +746,9 @@ int netlink_route_change(struct sockaddr_nl *snl, struct nlmsghdr *h,
return -1; return -1;
if (rtm->rtm_type == RTN_MULTICAST) if (rtm->rtm_type == RTN_MULTICAST)
netlink_route_change_read_multicast(snl, h, ns_id, startup); netlink_route_change_read_multicast(h, ns_id, startup);
else else
netlink_route_change_read_unicast(snl, h, ns_id, startup); netlink_route_change_read_unicast(h, ns_id, startup);
return 0; return 0;
} }
@ -1810,8 +1807,7 @@ int kernel_del_vtep(vni_t vni, struct interface *ifp, struct in_addr *vtep_ip)
((struct rtattr *)(((char *)(r)) + NLMSG_ALIGN(sizeof(struct ndmsg)))) ((struct rtattr *)(((char *)(r)) + NLMSG_ALIGN(sizeof(struct ndmsg))))
#endif #endif
static int netlink_macfdb_change(struct sockaddr_nl *snl, struct nlmsghdr *h, static int netlink_macfdb_change(struct nlmsghdr *h, int len, ns_id_t ns_id)
int len, ns_id_t ns_id)
{ {
struct ndmsg *ndm; struct ndmsg *ndm;
struct interface *ifp; struct interface *ifp;
@ -1946,8 +1942,7 @@ static int netlink_macfdb_change(struct sockaddr_nl *snl, struct nlmsghdr *h,
return zebra_vxlan_local_mac_del(ifp, br_if, &mac, vid); return zebra_vxlan_local_mac_del(ifp, br_if, &mac, vid);
} }
static int netlink_macfdb_table(struct sockaddr_nl *snl, struct nlmsghdr *h, static int netlink_macfdb_table(struct nlmsghdr *h, ns_id_t ns_id, int startup)
ns_id_t ns_id, int startup)
{ {
int len; int len;
struct ndmsg *ndm; struct ndmsg *ndm;
@ -1965,7 +1960,7 @@ static int netlink_macfdb_table(struct sockaddr_nl *snl, struct nlmsghdr *h,
if (ndm->ndm_family != AF_BRIDGE) if (ndm->ndm_family != AF_BRIDGE)
return 0; return 0;
return netlink_macfdb_change(snl, h, len, ns_id); return netlink_macfdb_change(h, len, ns_id);
} }
/* Request for MAC FDB information from the kernel */ /* Request for MAC FDB information from the kernel */
@ -2121,8 +2116,7 @@ static int netlink_macfdb_update(struct interface *ifp, vlanid_t vid,
(NUD_PERMANENT | NUD_NOARP | NUD_REACHABLE | NUD_PROBE | NUD_STALE \ (NUD_PERMANENT | NUD_NOARP | NUD_REACHABLE | NUD_PROBE | NUD_STALE \
| NUD_DELAY) | NUD_DELAY)
static int netlink_ipneigh_change(struct sockaddr_nl *snl, struct nlmsghdr *h, static int netlink_ipneigh_change(struct nlmsghdr *h, int len, ns_id_t ns_id)
int len, ns_id_t ns_id)
{ {
struct ndmsg *ndm; struct ndmsg *ndm;
struct interface *ifp; struct interface *ifp;
@ -2265,8 +2259,7 @@ static int netlink_ipneigh_change(struct sockaddr_nl *snl, struct nlmsghdr *h,
return zebra_vxlan_handle_kernel_neigh_del(ifp, link_if, &ip); return zebra_vxlan_handle_kernel_neigh_del(ifp, link_if, &ip);
} }
static int netlink_neigh_table(struct sockaddr_nl *snl, struct nlmsghdr *h, static int netlink_neigh_table(struct nlmsghdr *h, ns_id_t ns_id, int startup)
ns_id_t ns_id, int startup)
{ {
int len; int len;
struct ndmsg *ndm; struct ndmsg *ndm;
@ -2284,7 +2277,7 @@ static int netlink_neigh_table(struct sockaddr_nl *snl, struct nlmsghdr *h,
if (ndm->ndm_family != AF_INET && ndm->ndm_family != AF_INET6) if (ndm->ndm_family != AF_INET && ndm->ndm_family != AF_INET6)
return 0; return 0;
return netlink_neigh_change(snl, h, len); return netlink_neigh_change(h, len);
} }
/* Request for IP neighbor information from the kernel */ /* Request for IP neighbor information from the kernel */
@ -2344,8 +2337,7 @@ int netlink_neigh_read_for_vlan(struct zebra_ns *zns, struct interface *vlan_if)
return ret; return ret;
} }
int netlink_neigh_change(struct sockaddr_nl *snl, struct nlmsghdr *h, int netlink_neigh_change(struct nlmsghdr *h, ns_id_t ns_id)
ns_id_t ns_id)
{ {
int len; int len;
struct ndmsg *ndm; struct ndmsg *ndm;
@ -2361,13 +2353,13 @@ int netlink_neigh_change(struct sockaddr_nl *snl, struct nlmsghdr *h,
/* Is this a notification for the MAC FDB or IP neighbor table? */ /* Is this a notification for the MAC FDB or IP neighbor table? */
ndm = NLMSG_DATA(h); ndm = NLMSG_DATA(h);
if (ndm->ndm_family == AF_BRIDGE) if (ndm->ndm_family == AF_BRIDGE)
return netlink_macfdb_change(snl, h, len, ns_id); return netlink_macfdb_change(h, len, ns_id);
if (ndm->ndm_type != RTN_UNICAST) if (ndm->ndm_type != RTN_UNICAST)
return 0; return 0;
if (ndm->ndm_family == AF_INET || ndm->ndm_family == AF_INET6) if (ndm->ndm_family == AF_INET || ndm->ndm_family == AF_INET6)
return netlink_ipneigh_change(snl, h, len, ns_id); return netlink_ipneigh_change(h, len, ns_id);
return 0; return 0;
} }

View File

@ -58,12 +58,10 @@ void rt_netlink_init(void);
extern int netlink_mpls_multipath(int cmd, zebra_lsp_t *lsp); extern int netlink_mpls_multipath(int cmd, zebra_lsp_t *lsp);
extern int netlink_route_change(struct sockaddr_nl *snl, struct nlmsghdr *h, extern int netlink_route_change(struct nlmsghdr *h, ns_id_t ns_id, int startup);
ns_id_t ns_id, int startup);
extern int netlink_route_read(struct zebra_ns *zns); extern int netlink_route_read(struct zebra_ns *zns);
extern int netlink_neigh_change(struct sockaddr_nl *snl, struct nlmsghdr *h, extern int netlink_neigh_change(struct nlmsghdr *h, ns_id_t ns_id);
ns_id_t ns_id);
extern int netlink_macfdb_read(struct zebra_ns *zns); extern int netlink_macfdb_read(struct zebra_ns *zns);
extern int netlink_macfdb_read_for_bridge(struct zebra_ns *zns, extern int netlink_macfdb_read_for_bridge(struct zebra_ns *zns,
struct interface *ifp, struct interface *ifp,

View File

@ -166,8 +166,7 @@ void kernel_del_pbr_rule(struct zebra_pbr_rule *rule)
* notification of interest. The expectation is that if this corresponds * notification of interest. The expectation is that if this corresponds
* to a PBR rule added by FRR, it will be readded. * to a PBR rule added by FRR, it will be readded.
*/ */
int netlink_rule_change(struct sockaddr_nl *snl, struct nlmsghdr *h, int netlink_rule_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)
ns_id_t ns_id, int startup)
{ {
struct zebra_ns *zns; struct zebra_ns *zns;
struct fib_rule_hdr *frh; struct fib_rule_hdr *frh;

View File

@ -29,8 +29,7 @@
/* /*
* Handle netlink notification informing a rule add or delete. * Handle netlink notification informing a rule add or delete.
*/ */
extern int netlink_rule_change(struct sockaddr_nl *snl, struct nlmsghdr *h, extern int netlink_rule_change(struct nlmsghdr *h, ns_id_t ns_id, int startup);
ns_id_t ns_id, int startup);
/* /*
* Get to know existing PBR rules in the kernel - typically called at startup. * Get to know existing PBR rules in the kernel - typically called at startup.