From dc7b3caefbd8baccb7fc3787a774e78d1a96636f Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 10 Jan 2018 19:01:57 -0500 Subject: zebra: Add one-shot thread to recheck speed There are certain interfaces that when brought up and we receive the netlink notification about it, the speed of the interface is not set correctly. This creates a one-shot thread that will wait 15 seconds and then requery the speed and if it is different it will renotify the running daemons. The kernel should notify us on speed changes, unfortunately this is not done currently via a netlink message as you would think. As I understand it there is some in-fighting about the proper way to approach this issue and due to the way the kernel release cycle works we are a ways off from getting this fixed. This is a `hack` to make us work correctly while we wait for the true answer. Signed-off-by: Donald Sharp --- zebra/rt_socket.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'zebra/rt_socket.c') diff --git a/zebra/rt_socket.c b/zebra/rt_socket.c index 0d1a80e737..0c29f0650c 100644 --- a/zebra/rt_socket.c +++ b/zebra/rt_socket.c @@ -473,4 +473,9 @@ extern int kernel_interface_set_master(struct interface *master, return 0; } +uint32_t kernel_get_speed(struct interface *ifp) +{ + return ifp->speed; +} + #endif /* !HAVE_NETLINK */ -- cgit v1.2.3 From 8ecdb26ec08cc66ade06e3d325fceaae7bed76f2 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Sun, 21 Jan 2018 16:11:50 -0500 Subject: lib, zebra: Rename and place appropriately the label stack Fix and rename the label stack to be better named. Signed-off-by: Donald Sharp --- lib/mpls.h | 6 ++++++ lib/nexthop.c | 6 +++--- lib/nexthop.h | 9 +-------- zebra/rt_netlink.c | 4 ++-- zebra/rt_socket.c | 2 +- zebra/zebra_mpls.c | 4 ++-- 6 files changed, 15 insertions(+), 16 deletions(-) (limited to 'zebra/rt_socket.c') diff --git a/lib/mpls.h b/lib/mpls.h index bf98eecd81..6ef00375e8 100644 --- a/lib/mpls.h +++ b/lib/mpls.h @@ -81,6 +81,12 @@ typedef unsigned int mpls_lse_t; /* MPLS label value as a 32-bit (mostly we only care about the label value). */ typedef unsigned int mpls_label_t; +struct mpls_label_stack { + uint8_t num_labels; + uint8_t reserved[3]; + mpls_label_t label[0]; /* 1 or more labels */ +}; + /* The MPLS explicit-null label is 0 which means when you memset a mpls_label_t * to zero you have set that variable to explicit-null which was probably not * your intent. The work-around is to use one bit to indicate if the diff --git a/lib/nexthop.c b/lib/nexthop.c index f6b2c9788d..f531f27302 100644 --- a/lib/nexthop.c +++ b/lib/nexthop.c @@ -124,7 +124,7 @@ const char *nexthop_type_to_str(enum nexthop_types_t nh_type) */ int nexthop_labels_match(struct nexthop *nh1, struct nexthop *nh2) { - struct nexthop_label *nhl1, *nhl2; + struct mpls_label_stack *nhl1, *nhl2; nhl1 = nh1->nh_label; nhl2 = nh2->nh_label; @@ -210,12 +210,12 @@ void nexthops_free(struct nexthop *nexthop) void nexthop_add_labels(struct nexthop *nexthop, enum lsp_types_t type, u_int8_t num_labels, mpls_label_t *label) { - struct nexthop_label *nh_label; + struct mpls_label_stack *nh_label; int i; nexthop->nh_label_type = type; nh_label = XCALLOC(MTYPE_NH_LABEL, - sizeof(struct nexthop_label) + sizeof(struct mpls_label_stack) + num_labels * sizeof(mpls_label_t)); nh_label->num_labels = num_labels; for (i = 0; i < num_labels; i++) diff --git a/lib/nexthop.h b/lib/nexthop.h index a727f37057..753e66643d 100644 --- a/lib/nexthop.h +++ b/lib/nexthop.h @@ -55,13 +55,6 @@ enum blackhole_type { ((type) == NEXTHOP_TYPE_IFINDEX || (type) == NEXTHOP_TYPE_BLACKHOLE) \ ? (type) : ((type) | 1) -/* Nexthop label structure. */ -struct nexthop_label { - u_int8_t num_labels; - u_int8_t reserved[3]; - mpls_label_t label[0]; /* 1 or more labels. */ -}; - /* Nexthop structure. */ struct nexthop { struct nexthop *next; @@ -107,7 +100,7 @@ struct nexthop { enum lsp_types_t nh_label_type; /* Label(s) associated with this nexthop. */ - struct nexthop_label *nh_label; + struct mpls_label_stack *nh_label; }; /* The following for loop allows to iterate over the nexthop diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index a77814668d..2dc3771b25 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -803,7 +803,7 @@ static void _netlink_route_build_singlepath(const char *routedesc, int bytelen, struct rtmsg *rtmsg, size_t req_size, int cmd) { - struct nexthop_label *nh_label; + struct mpls_label_stack *nh_label; mpls_lse_t out_lse[MPLS_MAX_LABELS]; char label_buf[256]; @@ -1003,7 +1003,7 @@ static void _netlink_route_build_multipath(const char *routedesc, int bytelen, struct rtmsg *rtmsg, union g_addr **src) { - struct nexthop_label *nh_label; + struct mpls_label_stack *nh_label; mpls_lse_t out_lse[MPLS_MAX_LABELS]; char label_buf[256]; diff --git a/zebra/rt_socket.c b/zebra/rt_socket.c index 0c29f0650c..09fdf0b2d3 100644 --- a/zebra/rt_socket.c +++ b/zebra/rt_socket.c @@ -67,7 +67,7 @@ static int sin_masklen(struct in_addr mask) #endif /* HAVE_STRUCT_SOCKADDR_IN_SIN_LEN */ #ifdef __OpenBSD__ -static int kernel_rtm_add_labels(struct nexthop_label *nh_label, +static int kernel_rtm_add_labels(struct mpls_label_stack *nh_label, struct sockaddr_mpls *smpls) { if (nh_label->num_labels > 1) { diff --git a/zebra/zebra_mpls.c b/zebra/zebra_mpls.c index 4c6fb002dc..193aaa068a 100644 --- a/zebra/zebra_mpls.c +++ b/zebra/zebra_mpls.c @@ -104,7 +104,7 @@ static zebra_nhlfe_t *nhlfe_add(zebra_lsp_t *lsp, enum lsp_types_t lsp_type, ifindex_t ifindex, mpls_label_t out_label); static int nhlfe_del(zebra_nhlfe_t *snhlfe); static void nhlfe_out_label_update(zebra_nhlfe_t *nhlfe, - struct nexthop_label *nh_label); + struct mpls_label_stack *nh_label); static int mpls_lsp_uninstall_all(struct hash *lsp_table, zebra_lsp_t *lsp, enum lsp_types_t type); static int mpls_static_lsp_uninstall_all(struct zebra_vrf *zvrf, @@ -1217,7 +1217,7 @@ static int nhlfe_del(zebra_nhlfe_t *nhlfe) * Update label for NHLFE entry. */ static void nhlfe_out_label_update(zebra_nhlfe_t *nhlfe, - struct nexthop_label *nh_label) + struct mpls_label_stack *nh_label) { nhlfe->nexthop->nh_label->label[0] = nh_label->label[0]; } -- cgit v1.2.3 From 7d974ba3b72ce8c4e46201a3c8b60e1680406883 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 24 Jan 2018 08:22:57 -0500 Subject: zebra: Modify southbound interface to pass `struct route_node` The route_node that we are working on is going to be interesting to the kernel_route_rib_pass_fail. So I am setting up the code to allow me to pass it. This will be done in a subsuquent commit. Signed-off-by: Donald Sharp --- zebra/rt.h | 8 +++++--- zebra/rt_netlink.c | 9 +++++---- zebra/rt_socket.c | 9 +++++---- zebra/zebra_rib.c | 7 ++++--- 4 files changed, 19 insertions(+), 14 deletions(-) (limited to 'zebra/rt_socket.c') diff --git a/zebra/rt.h b/zebra/rt.h index bb4ff5bee8..54d45b889a 100644 --- a/zebra/rt.h +++ b/zebra/rt.h @@ -60,15 +60,17 @@ enum southbound_results { * semantics so we will end up with a delete than * a re-add. */ -extern void kernel_route_rib(struct prefix *p, struct prefix *src_p, - struct route_entry *old, struct route_entry *new); +extern void kernel_route_rib(struct route_node *rn, struct prefix *p, + struct prefix *src_p, struct route_entry *old, + struct route_entry *new); /* * So route install/failure may not be immediately known * so let's separate it out and allow the result to * be passed back up. */ -extern void kernel_route_rib_pass_fail(struct prefix *p, +extern void kernel_route_rib_pass_fail(struct route_node *rn, + struct prefix *p, struct route_entry *re, enum southbound_results res); diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index 0221162a30..20cc292e11 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -1642,8 +1642,9 @@ int kernel_get_ipmr_sg_stats(struct zebra_vrf *zvrf, void *in) return suc; } -void kernel_route_rib(struct prefix *p, struct prefix *src_p, - struct route_entry *old, struct route_entry *new) +void kernel_route_rib(struct route_node *rn, struct prefix *p, + struct prefix *src_p, struct route_entry *old, + struct route_entry *new) { int ret = 0; @@ -1672,7 +1673,7 @@ void kernel_route_rib(struct prefix *p, struct prefix *src_p, ret = netlink_route_multipath(RTM_NEWROUTE, p, src_p, new, 0); } - kernel_route_rib_pass_fail(p, new, + kernel_route_rib_pass_fail(rn, p, new, (!ret) ? SOUTHBOUND_INSTALL_SUCCESS : SOUTHBOUND_INSTALL_FAILURE); @@ -1682,7 +1683,7 @@ void kernel_route_rib(struct prefix *p, struct prefix *src_p, if (old) { ret = netlink_route_multipath(RTM_DELROUTE, p, src_p, old, 0); - kernel_route_rib_pass_fail(p, old, + kernel_route_rib_pass_fail(rn, p, old, (!ret) ? SOUTHBOUND_DELETE_SUCCESS : SOUTHBOUND_DELETE_FAILURE); diff --git a/zebra/rt_socket.c b/zebra/rt_socket.c index 09fdf0b2d3..6d4af1203c 100644 --- a/zebra/rt_socket.c +++ b/zebra/rt_socket.c @@ -387,8 +387,9 @@ static int kernel_rtm(int cmd, struct prefix *p, struct route_entry *re) return 0; } -void kernel_route_rib(struct prefix *p, struct prefix *src_p, - struct route_entry *old, struct route_entry *new) +void kernel_route_rib(struct route_node *rn, struct prefix *p, + struct prefix *src_p, struct route_entry *old, + struct route_entry *new) { int route = 0; @@ -410,12 +411,12 @@ void kernel_route_rib(struct prefix *p, struct prefix *src_p, zlog_err("Can't lower privileges"); if (new) { - kernel_route_rib_pass_fail(p, new, + kernel_route_rib_pass_fail(rn, p, new, (!route) ? SOUTHBOUND_INSTALL_SUCCESS : SOUTHBOUND_INSTALL_FAILURE); } else { - kernel_route_rib_pass_fail(p, old, + kernel_route_rib_pass_fail(rn, p, old, (!route) ? SOUTHBOUND_DELETE_SUCCESS : SOUTHBOUND_DELETE_FAILURE); diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index 78077a4b3d..83eff7bdcf 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -998,7 +998,8 @@ int zebra_rib_labeled_unicast(struct route_entry *re) return 1; } -void kernel_route_rib_pass_fail(struct prefix *p, struct route_entry *re, +void kernel_route_rib_pass_fail(struct route_node *rn, struct prefix *p, + struct route_entry *re, enum southbound_results res) { struct nexthop *nexthop; @@ -1083,7 +1084,7 @@ void rib_install_kernel(struct route_node *rn, struct route_entry *re, * the kernel. */ hook_call(rib_update, rn, "installing in kernel"); - kernel_route_rib(p, src_p, old, re); + kernel_route_rib(rn, p, src_p, old, re); zvrf->installs++; return; @@ -1110,7 +1111,7 @@ void rib_uninstall_kernel(struct route_node *rn, struct route_entry *re) * the kernel. */ hook_call(rib_update, rn, "uninstalling from kernel"); - kernel_route_rib(p, src_p, re, NULL); + kernel_route_rib(rn, p, src_p, re, NULL); zvrf->removals++; return; -- cgit v1.2.3