diff options
author | Philippe Guibert <philippe.guibert@6wind.com> | 2019-12-16 13:34:00 +0100 |
---|---|---|
committer | Philippe Guibert <philippe.guibert@6wind.com> | 2021-04-09 18:29:58 +0200 |
commit | 541025d6ffe2bee713cef8d5572a15d2b3dc5d11 (patch) | |
tree | c6c3ca7d13cdf247d344a597902f750f932a3b38 | |
parent | zebra: fixes NDA_DST in netlink_neigh_update() function (diff) | |
download | frr-541025d6ffe2bee713cef8d5572a15d2b3dc5d11.tar.xz frr-541025d6ffe2bee713cef8d5572a15d2b3dc5d11.zip |
zebra: handler for configuring neighbor table
neighbor table api in zebra is added. a netlink api is created for that.
the handler is called from the api defined in the previous commit.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Diffstat (limited to '')
-rw-r--r-- | zebra/rt.h | 1 | ||||
-rw-r--r-- | zebra/rt_netlink.c | 52 | ||||
-rw-r--r-- | zebra/rt_socket.c | 5 | ||||
-rw-r--r-- | zebra/zapi_msg.c | 23 |
4 files changed, 81 insertions, 0 deletions
diff --git a/zebra/rt.h b/zebra/rt.h index f79ddbe95..01d324616 100644 --- a/zebra/rt.h +++ b/zebra/rt.h @@ -81,6 +81,7 @@ extern int mpls_kernel_init(void); extern uint32_t kernel_get_speed(struct interface *ifp, int *error); extern int kernel_get_ipmr_sg_stats(struct zebra_vrf *zvrf, void *mroute); +extern int kernel_configure_arp(struct interface *ifp, int family, ns_id_t ns_id); /* * Southbound Initialization routines to get initial starting * state. diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index 90d809475..a7fbbf133 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -1537,6 +1537,52 @@ static void _netlink_mpls_debug(int cmd, uint32_t label, const char *routedesc) routedesc, nl_msg_type_to_str(cmd), label); } +static int netlink_configure_arp(struct interface *ifp, int family, ns_id_t ns_id) +{ + struct { + struct nlmsghdr n; + struct ndtmsg ndtm; + char buf[256]; + } req; + struct zebra_ns *zns = zebra_ns_lookup(ns_id); + struct rtattr *nest; + uint32_t val; + + memset(&req, 0, sizeof(req)); + + req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct ndtmsg)); + req.n.nlmsg_flags = NLM_F_REQUEST | NLM_F_REPLACE; + req.n.nlmsg_type = RTM_SETNEIGHTBL; + req.n.nlmsg_pid = zns->netlink_cmd.snl.nl_pid; + + req.ndtm.ndtm_family = family; + + nl_attr_put(&req.n, sizeof(req), NDTA_NAME, family == AF_INET ? "arp_cache" : + "ndisc_cache", 10); + + nest = nl_attr_nest(&req.n, sizeof(req), NDTA_PARMS); + if (nest == NULL) + return; + if (!nl_attr_put(&req.n, sizeof(req), NDTPA_IFINDEX, &ifp->ifindex, + sizeof(ifp->ifindex))) + return 0; + val = 1; + if (!nl_attr_put(&req.n, sizeof(req), NDTPA_APP_PROBES, &val, + sizeof(val))) + return 0; + val = 0; + if (!nl_attr_put(&req.n, sizeof(req), NDTPA_MCAST_PROBES, &val, + sizeof(val))) + return 0; + if (!nl_attr_put(&req.n, sizeof(req), NDTPA_UCAST_PROBES, &val, + sizeof(val))) + return 0; + nl_attr_nest_end(&req.n, nest); + + return netlink_talk(netlink_talk_filter, &req.n, &zns->netlink_cmd, zns, + 0); +} + static int netlink_neigh_update(int cmd, int ifindex, void *addr, char *lla, int llalen, ns_id_t ns_id, uint8_t family, bool permanent, uint8_t protocol) @@ -3789,6 +3835,12 @@ netlink_put_neigh_update_msg(struct nl_batch *bth, struct zebra_dplane_ctx *ctx) false); } +int kernel_configure_arp(struct interface *ifp, int family, + ns_id_t ns_id) +{ + return netlink_configure_arp(ifp, family, ns_id); +} + /* * MPLS label forwarding table change via netlink interface, using dataplane * context information. diff --git a/zebra/rt_socket.c b/zebra/rt_socket.c index 006513ac9..cbbc9b28f 100644 --- a/zebra/rt_socket.c +++ b/zebra/rt_socket.c @@ -394,6 +394,11 @@ enum zebra_dplane_result kernel_mac_update_ctx(struct zebra_dplane_ctx *ctx) return ZEBRA_DPLANE_REQUEST_SUCCESS; } +int kernel_configure_arp(struct interface *ifp, int family, ns_id_t ns_id) +{ + return 0; +} + extern int kernel_interface_set_master(struct interface *master, struct interface *slave) { diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c index 909b3b8ac..e880a6d7b 100644 --- a/zebra/zapi_msg.c +++ b/zebra/zapi_msg.c @@ -3279,6 +3279,28 @@ stream_failure: return; } +static inline void zebra_configure_arp(ZAPI_HANDLER_ARGS) +{ + struct stream *s; + int fam; + ifindex_t idx; + struct interface *ifp; + ns_id_t ns_id; + + s = msg; + STREAM_GETC(s, fam); + if (fam != AF_INET && fam != AF_INET6) + return; + STREAM_GETL(s, idx); + ifp = if_lookup_by_index_per_ns(zvrf->zns, idx); + if (!ifp) + return; + ns_id = zvrf->zns->ns_id; + kernel_configure_arp(ifp, fam, ns_id); +stream_failure: + return; +} + static inline void zebra_neigh_add(ZAPI_HANDLER_ARGS) { struct stream *s; @@ -3513,6 +3535,7 @@ void (*const zserv_handlers[])(ZAPI_HANDLER_ARGS) = { [ZEBRA_NEIGH_DEL] = zebra_neigh_del, [ZEBRA_NHRP_NEIGH_REGISTER] = zebra_neigh_register, [ZEBRA_NHRP_NEIGH_UNREGISTER] = zebra_neigh_unregister, + [ZEBRA_CONFIGURE_ARP] = zebra_configure_arp, }; /* |