summaryrefslogtreecommitdiff
path: root/nhrpd
diff options
context:
space:
mode:
authorPhilippe Guibert <philippe.guibert@6wind.com>2019-12-13 18:09:11 +0100
committerPhilippe Guibert <philippe.guibert@6wind.com>2021-04-09 18:29:58 +0200
commit05657ec2b78911e4b7bae3692fa27cd81945ad73 (patch)
tree49c6ae5fbc886b79cbbd0a4fbfa8c63659d870c0 /nhrpd
parentb3b7510464952d0f2f024a31c5d4aede0fcabd75 (diff)
nhrp, lib, zebra: add/del neighbor entry possible from nhrp
a zebra api is extended to offer ability to add or remove neighbor entry from daemon. Also this extension makes possible to add neigh entry, not only between IPs and macs, but also between IPs and NBMA IPs. This API supports configuring ipv6/ipv4 entries with ipv4/ipv6 lladdr. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Diffstat (limited to 'nhrpd')
-rw-r--r--nhrpd/netlink_arp.c23
-rw-r--r--nhrpd/nhrp_route.c26
-rw-r--r--nhrpd/nhrpd.h3
3 files changed, 30 insertions, 22 deletions
diff --git a/nhrpd/netlink_arp.c b/nhrpd/netlink_arp.c
index bb8e73ab1e..bf5d74c25c 100644
--- a/nhrpd/netlink_arp.c
+++ b/nhrpd/netlink_arp.c
@@ -34,28 +34,7 @@ typedef void (*netlink_dispatch_f)(struct nlmsghdr *msg, struct zbuf *zb);
void netlink_update_binding(struct interface *ifp, union sockunion *proto,
union sockunion *nbma)
{
- struct nlmsghdr *n;
- struct ndmsg *ndm;
- struct zbuf *zb = zbuf_alloc(512);
-
- n = znl_nlmsg_push(zb, nbma ? RTM_NEWNEIGH : RTM_DELNEIGH,
- NLM_F_REQUEST | NLM_F_REPLACE | NLM_F_CREATE);
- ndm = znl_push(zb, sizeof(*ndm));
- *ndm = (struct ndmsg){
- .ndm_family = sockunion_family(proto),
- .ndm_ifindex = ifp->ifindex,
- .ndm_type = RTN_UNICAST,
- .ndm_state = nbma ? NUD_REACHABLE : NUD_FAILED,
- };
- znl_rta_push(zb, NDA_DST, sockunion_get_addr(proto),
- family2addrsize(sockunion_family(proto)));
- if (nbma)
- znl_rta_push(zb, NDA_LLADDR, sockunion_get_addr(nbma),
- family2addrsize(sockunion_family(nbma)));
- znl_nlmsg_complete(zb, n);
- zbuf_send(zb, netlink_req_fd);
- zbuf_recv(zb, netlink_req_fd);
- zbuf_free(zb);
+ nhrp_send_zebra_nbr(proto, nbma, ifp);
}
static void netlink_log_register(int fd, int group)
diff --git a/nhrpd/nhrp_route.c b/nhrpd/nhrp_route.c
index 746b585ede..06a9564e81 100644
--- a/nhrpd/nhrp_route.c
+++ b/nhrpd/nhrp_route.c
@@ -392,6 +392,32 @@ static void nhrp_table_node_cleanup(struct route_table *table,
XFREE(MTYPE_NHRP_ROUTE, node->info);
}
+void nhrp_send_zebra_nbr(union sockunion *in,
+ union sockunion *out,
+ struct interface *ifp)
+{
+ struct stream *s;
+
+ if (!zclient || zclient->sock < 0)
+ return;
+ s = zclient->obuf;
+ stream_reset(s);
+ zclient_create_header(s,
+ out ? ZEBRA_NEIGH_ADD : ZEBRA_NEIGH_DEL,
+ ifp->vrf_id);
+ stream_putc(s, sockunion_family(in));
+ stream_write(s, sockunion_get_addr(in), sockunion_get_addrlen(in));
+ if (out) {
+ stream_putc(s, sockunion_family(out));
+ stream_write(s, sockunion_get_addr(out),
+ sockunion_get_addrlen(out));
+ }
+ stream_putl(s, ifp->ifindex);
+
+ stream_putw_at(s, 0, stream_get_endp(s));
+ zclient_send_message(zclient);
+}
+
void nhrp_zebra_terminate(void)
{
nhrp_zebra_register_neigh(VRF_DEFAULT, AFI_IP, false);
diff --git a/nhrpd/nhrpd.h b/nhrpd/nhrpd.h
index 6e7ddda18d..0f4635d3db 100644
--- a/nhrpd/nhrpd.h
+++ b/nhrpd/nhrpd.h
@@ -88,6 +88,9 @@ static inline int notifier_active(struct notifier_list *l)
void nhrp_zebra_init(void);
void nhrp_zebra_terminate(void);
+void nhrp_send_zebra_nbr(union sockunion *in,
+ union sockunion *out,
+ struct interface *ifp);
struct zbuf;
struct nhrp_vc;