summaryrefslogtreecommitdiff
path: root/zebra/rt_netlink.c
diff options
context:
space:
mode:
Diffstat (limited to 'zebra/rt_netlink.c')
-rw-r--r--zebra/rt_netlink.c81
1 files changed, 48 insertions, 33 deletions
diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c
index 38f8140db2..780b601734 100644
--- a/zebra/rt_netlink.c
+++ b/zebra/rt_netlink.c
@@ -861,6 +861,12 @@ static int netlink_route_change_read_unicast(struct nlmsghdr *h, ns_id_t ns_id,
}
memcpy(&src_p.prefix, src, 16);
src_p.prefixlen = rtm->rtm_src_len;
+ } else {
+ /* We only handle the AFs we handle... */
+ if (IS_ZEBRA_DEBUG_KERNEL)
+ zlog_debug("%s: unknown address-family %u", __func__,
+ rtm->rtm_family);
+ return 0;
}
/*
@@ -1165,7 +1171,7 @@ int netlink_route_read(struct zebra_ns *zns)
if (ret < 0)
return ret;
ret = netlink_parse_info(netlink_route_change_read_unicast,
- &zns->netlink_cmd, &dp_info, 0, 1);
+ &zns->netlink_cmd, &dp_info, 0, true);
if (ret < 0)
return ret;
@@ -1174,7 +1180,7 @@ int netlink_route_read(struct zebra_ns *zns)
if (ret < 0)
return ret;
ret = netlink_parse_info(netlink_route_change_read_unicast,
- &zns->netlink_cmd, &dp_info, 0, 1);
+ &zns->netlink_cmd, &dp_info, 0, true);
if (ret < 0)
return ret;
@@ -1725,12 +1731,11 @@ static bool _netlink_route_build_multipath(const struct prefix *p,
return true;
}
-static inline bool _netlink_mpls_build_singlepath(const struct prefix *p,
- const char *routedesc,
- const zebra_nhlfe_t *nhlfe,
- struct nlmsghdr *nlmsg,
- struct rtmsg *rtmsg,
- size_t req_size, int cmd)
+static inline bool
+_netlink_mpls_build_singlepath(const struct prefix *p, const char *routedesc,
+ const struct zebra_nhlfe *nhlfe,
+ struct nlmsghdr *nlmsg, struct rtmsg *rtmsg,
+ size_t req_size, int cmd)
{
int bytelen;
uint8_t family;
@@ -1745,7 +1750,7 @@ static inline bool _netlink_mpls_build_singlepath(const struct prefix *p,
static inline bool
_netlink_mpls_build_multipath(const struct prefix *p, const char *routedesc,
- const zebra_nhlfe_t *nhlfe,
+ const struct zebra_nhlfe *nhlfe,
struct nlmsghdr *nlmsg, size_t req_size,
struct rtmsg *rtmsg, const union g_addr **src)
{
@@ -1805,7 +1810,7 @@ static int netlink_neigh_update(int cmd, int ifindex, void *addr, char *lla,
nl_attr_put(&req.n, sizeof(req), NDA_LLADDR, lla, llalen);
return netlink_talk(netlink_talk_filter, &req.n, &zns->netlink_cmd, zns,
- 0);
+ false);
}
static bool nexthop_set_src(const struct nexthop *nexthop, int family,
@@ -2263,7 +2268,7 @@ int kernel_get_ipmr_sg_stats(struct zebra_vrf *zvrf, void *in)
nl_attr_put32(&req.n, sizeof(req), RTA_TABLE, actual_table);
suc = netlink_talk(netlink_route_change_read_multicast, &req.n,
- &zns->netlink_cmd, zns, 0);
+ &zns->netlink_cmd, zns, false);
mroute = NULL;
return suc;
@@ -3014,7 +3019,7 @@ int netlink_nexthop_read(struct zebra_ns *zns)
if (ret < 0)
return ret;
ret = netlink_parse_info(netlink_nexthop_change, &zns->netlink_cmd,
- &dp_info, 0, 1);
+ &dp_info, 0, true);
if (!ret)
/* If we succesfully read in nexthop objects,
@@ -3422,7 +3427,7 @@ int netlink_macfdb_read(struct zebra_ns *zns)
/* We are reading entire table. */
filter_vlan = 0;
ret = netlink_parse_info(netlink_macfdb_table, &zns->netlink_cmd,
- &dp_info, 0, 1);
+ &dp_info, 0, true);
return ret;
}
@@ -3456,7 +3461,7 @@ int netlink_macfdb_read_for_bridge(struct zebra_ns *zns, struct interface *ifp,
if (ret < 0)
return ret;
ret = netlink_parse_info(netlink_macfdb_table, &zns->netlink_cmd,
- &dp_info, 0, 0);
+ &dp_info, 0, false);
/* Reset VLAN filter. */
filter_vlan = 0;
@@ -3466,10 +3471,9 @@ int netlink_macfdb_read_for_bridge(struct zebra_ns *zns, struct interface *ifp,
/* Request for MAC FDB for a specific MAC address in VLAN from the kernel */
static int netlink_request_specific_mac_in_bridge(struct zebra_ns *zns,
- int family,
- int type,
+ int family, int type,
struct interface *br_if,
- struct ethaddr *mac,
+ const struct ethaddr *mac,
vlanid_t vid)
{
struct {
@@ -3506,7 +3510,7 @@ static int netlink_request_specific_mac_in_bridge(struct zebra_ns *zns,
int netlink_macfdb_read_specific_mac(struct zebra_ns *zns,
struct interface *br_if,
- struct ethaddr *mac, vlanid_t vid)
+ const struct ethaddr *mac, vlanid_t vid)
{
int ret = 0;
struct zebra_dplane_info dp_info;
@@ -3522,7 +3526,7 @@ int netlink_macfdb_read_specific_mac(struct zebra_ns *zns,
return ret;
ret = netlink_parse_info(netlink_macfdb_table, &zns->netlink_cmd,
- &dp_info, 1, 0);
+ &dp_info, 1, false);
return ret;
}
@@ -3653,6 +3657,15 @@ static void netlink_handle_5549(struct ndmsg *ndm, struct zebra_if *zif,
#define NUD_LOCAL_ACTIVE \
(NUD_PERMANENT | NUD_NOARP | NUD_REACHABLE)
+static int netlink_nbr_entry_state_to_zclient(int nbr_state)
+{
+ /* an exact match is done between
+ * - netlink neighbor state values: NDM_XXX (see in linux/neighbour.h)
+ * - zclient neighbor state values: ZEBRA_NEIGH_STATE_XXX
+ * (see in lib/zclient.h)
+ */
+ return nbr_state;
+}
static int netlink_ipneigh_change(struct nlmsghdr *h, int len, ns_id_t ns_id)
{
struct ndmsg *ndm;
@@ -3731,7 +3744,6 @@ static int netlink_ipneigh_change(struct nlmsghdr *h, int len, ns_id_t ns_id)
if (tb[NDA_LLADDR]) {
/* copy LLADDR information */
l2_len = RTA_PAYLOAD(tb[NDA_LLADDR]);
- memcpy(&mac, RTA_DATA(tb[NDA_LLADDR]), l2_len);
}
if (l2_len == IPV4_MAX_BYTELEN || l2_len == 0) {
union sockunion link_layer_ipv4;
@@ -3739,11 +3751,13 @@ static int netlink_ipneigh_change(struct nlmsghdr *h, int len, ns_id_t ns_id)
if (l2_len) {
sockunion_family(&link_layer_ipv4) = AF_INET;
memcpy((void *)sockunion_get_addr(&link_layer_ipv4),
- &mac, l2_len);
+ RTA_DATA(tb[NDA_LLADDR]), l2_len);
} else
sockunion_family(&link_layer_ipv4) = AF_UNSPEC;
- zsend_nhrp_neighbor_notify(cmd, ifp, &ip, ndm->ndm_state,
- &link_layer_ipv4);
+ zsend_nhrp_neighbor_notify(
+ cmd, ifp, &ip,
+ netlink_nbr_entry_state_to_zclient(ndm->ndm_state),
+ &link_layer_ipv4);
}
if (h->nlmsg_type == RTM_GETNEIGH)
@@ -3915,7 +3929,7 @@ int netlink_neigh_read(struct zebra_ns *zns)
if (ret < 0)
return ret;
ret = netlink_parse_info(netlink_neigh_table, &zns->netlink_cmd,
- &dp_info, 0, 1);
+ &dp_info, 0, true);
return ret;
}
@@ -3936,7 +3950,7 @@ int netlink_neigh_read_for_vlan(struct zebra_ns *zns, struct interface *vlan_if)
if (ret < 0)
return ret;
ret = netlink_parse_info(netlink_neigh_table, &zns->netlink_cmd,
- &dp_info, 0, 0);
+ &dp_info, 0, false);
return ret;
}
@@ -3946,7 +3960,8 @@ int netlink_neigh_read_for_vlan(struct zebra_ns *zns, struct interface *vlan_if)
* read using netlink interface.
*/
static int netlink_request_specific_neigh_in_vlan(struct zebra_ns *zns,
- int type, struct ipaddr *ip,
+ int type,
+ const struct ipaddr *ip,
ifindex_t ifindex)
{
struct {
@@ -3983,8 +3998,8 @@ static int netlink_request_specific_neigh_in_vlan(struct zebra_ns *zns,
return netlink_request(&zns->netlink_cmd, &req);
}
-int netlink_neigh_read_specific_ip(struct ipaddr *ip,
- struct interface *vlan_if)
+int netlink_neigh_read_specific_ip(const struct ipaddr *ip,
+ struct interface *vlan_if)
{
int ret = 0;
struct zebra_ns *zns;
@@ -4006,7 +4021,7 @@ int netlink_neigh_read_specific_ip(struct ipaddr *ip,
return ret;
ret = netlink_parse_info(netlink_neigh_table, &zns->netlink_cmd,
- &dp_info, 1, 0);
+ &dp_info, 1, false);
return ret;
}
@@ -4235,7 +4250,7 @@ ssize_t netlink_mpls_multipath_msg_encode(int cmd, struct zebra_dplane_ctx *ctx,
{
mpls_lse_t lse;
const struct nhlfe_list_head *head;
- const zebra_nhlfe_t *nhlfe;
+ const struct zebra_nhlfe *nhlfe;
struct nexthop *nexthop = NULL;
unsigned int nexthop_num;
const char *routedesc;
@@ -4426,7 +4441,7 @@ static int netlink_fdb_nh_update(uint32_t nh_id, struct in_addr vtep_ip)
}
return netlink_talk(netlink_talk_filter, &req.n, &zns->netlink_cmd, zns,
- 0);
+ false);
}
static int netlink_fdb_nh_del(uint32_t nh_id)
@@ -4461,7 +4476,7 @@ static int netlink_fdb_nh_del(uint32_t nh_id)
}
return netlink_talk(netlink_talk_filter, &req.n, &zns->netlink_cmd, zns,
- 0);
+ false);
}
static int netlink_fdb_nhg_update(uint32_t nhg_id, uint32_t nh_cnt,
@@ -4521,7 +4536,7 @@ static int netlink_fdb_nhg_update(uint32_t nhg_id, uint32_t nh_cnt,
}
return netlink_talk(netlink_talk_filter, &req.n, &zns->netlink_cmd, zns,
- 0);
+ false);
}
static int netlink_fdb_nhg_del(uint32_t nhg_id)