1 /* Kernel communication using routing socket.
2 * Copyright (C) 1999 Kunihiro Ishiguro
4 * This file is part of GNU Zebra.
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #include <net/if_types.h>
27 #include <netmpls/mpls.h>
32 #include "sockunion.h"
33 #include "connected.h"
41 #include "lib_errors.h"
44 #include "zebra/interface.h"
45 #include "zebra/zebra_router.h"
46 #include "zebra/debug.h"
47 #include "zebra/kernel_socket.h"
48 #include "zebra/rib.h"
49 #include "zebra/zebra_errors.h"
50 #include "zebra/zebra_ptm.h"
52 extern struct zebra_privs_t zserv_privs
;
55 * Historically, the BSD routing socket has aligned data following a
56 * struct sockaddr to sizeof(long), which was 4 bytes on some
57 * platforms, and 8 bytes on others. NetBSD 6 changed the routing
58 * socket to align to sizeof(uint64_t), which is 8 bytes. OS X
59 * appears to align to sizeof(int), which is 4 bytes.
61 * Alignment of zero-sized sockaddrs is nonsensical, but historically
62 * BSD defines RT_ROUNDUP(0) to be the alignment interval (rather than
63 * 0). We follow this practice without questioning it, but it is a
64 * bug if frr calls ROUNDUP with 0.
67 #define ROUNDUP_TYPE int
69 #define ROUNDUP_TYPE long
73 * Because of these varying conventions, the only sane approach is for
74 * the <net/route.h> header to define some flavor of ROUNDUP macro.
77 /* OS X (Xcode as of 2014-12) is known not to define RT_ROUNDUP */
78 #if defined(RT_ROUNDUP)
79 #define ROUNDUP(a) RT_ROUNDUP(a)
80 #endif /* defined(RT_ROUNDUP) */
83 * If ROUNDUP has not yet been defined in terms of platform-provided
84 * defines, attempt to cope with heuristics.
89 * If you're porting to a platform that changed RT_ROUNDUP but doesn't
90 * have it in its headers, this will break rather obviously and you'll
91 * have to fix it here.
94 ((a) > 0 ? (1 + (((a)-1) | (sizeof(ROUNDUP_TYPE) - 1))) \
95 : sizeof(ROUNDUP_TYPE))
97 #endif /* defined(ROUNDUP) */
101 /* SAROUNDUP is the only thing we need, and SA_SIZE provides that */
102 #define SAROUNDUP(a) SA_SIZE(a)
105 * Given a pointer (sockaddr or void *), return the number of bytes
106 * taken up by the sockaddr and any padding needed for alignment.
108 #if defined(HAVE_STRUCT_SOCKADDR_SA_LEN)
109 #define SAROUNDUP(X) ROUNDUP(((struct sockaddr *)(X))->sa_len)
112 * One would hope all fixed-size structure definitions are aligned,
113 * but round them up nonetheless.
115 #define SAROUNDUP(X) \
116 (((struct sockaddr *)(X))->sa_family == AF_INET \
117 ? ROUNDUP(sizeof(struct sockaddr_in)) \
118 : (((struct sockaddr *)(X))->sa_family == AF_INET6 \
119 ? ROUNDUP(sizeof(struct sockaddr_in6)) \
120 : (((struct sockaddr *)(X))->sa_family == AF_LINK \
121 ? ROUNDUP(sizeof(struct sockaddr_dl)) \
122 : sizeof(struct sockaddr))))
123 #endif /* HAVE_STRUCT_SOCKADDR_SA_LEN */
125 #endif /* !SA_SIZE */
127 /* Routing socket message types. */
128 const struct message rtm_type_str
[] = {{RTM_ADD
, "RTM_ADD"},
129 {RTM_DELETE
, "RTM_DELETE"},
130 {RTM_CHANGE
, "RTM_CHANGE"},
131 {RTM_GET
, "RTM_GET"},
132 {RTM_LOSING
, "RTM_LOSING"},
133 {RTM_REDIRECT
, "RTM_REDIRECT"},
134 {RTM_MISS
, "RTM_MISS"},
136 {RTM_LOCK
, "RTM_LOCK"},
137 #endif /* RTM_LOCK */
139 {RTM_OLDADD
, "RTM_OLDADD"},
140 #endif /* RTM_OLDADD */
142 {RTM_OLDDEL
, "RTM_OLDDEL"},
143 #endif /* RTM_OLDDEL */
145 {RTM_RESOLVE
, "RTM_RESOLVE"},
146 #endif /* RTM_RESOLVE */
147 {RTM_NEWADDR
, "RTM_NEWADDR"},
148 {RTM_DELADDR
, "RTM_DELADDR"},
149 {RTM_IFINFO
, "RTM_IFINFO"},
151 {RTM_OIFINFO
, "RTM_OIFINFO"},
152 #endif /* RTM_OIFINFO */
154 {RTM_NEWMADDR
, "RTM_NEWMADDR"},
155 #endif /* RTM_NEWMADDR */
157 {RTM_DELMADDR
, "RTM_DELMADDR"},
158 #endif /* RTM_DELMADDR */
159 #ifdef RTM_IFANNOUNCE
160 {RTM_IFANNOUNCE
, "RTM_IFANNOUNCE"},
161 #endif /* RTM_IFANNOUNCE */
164 static const struct message rtm_flag_str
[] = {{RTF_UP
, "UP"},
165 {RTF_GATEWAY
, "GATEWAY"},
167 {RTF_REJECT
, "REJECT"},
168 {RTF_DYNAMIC
, "DYNAMIC"},
169 {RTF_MODIFIED
, "MODIFIED"},
173 #endif /* RTF_MASK */
175 {RTF_CLONING
, "CLONING"},
176 #endif /* RTF_CLONING */
178 {RTF_XRESOLVE
, "XRESOLVE"},
179 #endif /* RTF_XRESOLVE */
181 {RTF_LLINFO
, "LLINFO"},
182 #endif /* RTF_LLINFO */
183 {RTF_STATIC
, "STATIC"},
184 {RTF_BLACKHOLE
, "BLACKHOLE"},
186 {RTF_PRIVATE
, "PRIVATE"},
187 #endif /* RTF_PRIVATE */
188 {RTF_PROTO1
, "PROTO1"},
189 {RTF_PROTO2
, "PROTO2"},
191 {RTF_PRCLONING
, "PRCLONING"},
192 #endif /* RTF_PRCLONING */
194 {RTF_WASCLONED
, "WASCLONED"},
195 #endif /* RTF_WASCLONED */
197 {RTF_PROTO3
, "PROTO3"},
198 #endif /* RTF_PROTO3 */
200 {RTF_PINNED
, "PINNED"},
201 #endif /* RTF_PINNED */
203 {RTF_LOCAL
, "LOCAL"},
204 #endif /* RTF_LOCAL */
206 {RTF_BROADCAST
, "BROADCAST"},
207 #endif /* RTF_BROADCAST */
209 {RTF_MULTICAST
, "MULTICAST"},
210 #endif /* RTF_MULTICAST */
212 {RTF_MULTIRT
, "MULTIRT"},
213 #endif /* RTF_MULTIRT */
215 {RTF_SETSRC
, "SETSRC"},
216 #endif /* RTF_SETSRC */
219 /* Kernel routing update socket. */
220 int routing_sock
= -1;
222 /* Kernel dataplane routing update socket, used in the dataplane pthread
225 int dplane_routing_sock
= -1;
227 /* Yes I'm checking ugly routing socket behavior. */
230 size_t _rta_get(caddr_t sap
, void *destp
, size_t destlen
, bool checkaf
);
231 size_t rta_get(caddr_t sap
, void *dest
, size_t destlen
);
232 size_t rta_getattr(caddr_t sap
, void *destp
, size_t destlen
);
233 size_t rta_getsdlname(caddr_t sap
, void *dest
, short *destlen
);
234 const char *rtatostr(unsigned int flags
, char *buf
, size_t buflen
);
236 /* Supported address family check. */
237 static inline int af_check(int family
)
239 if (family
== AF_INET
)
241 if (family
== AF_INET6
)
246 size_t _rta_get(caddr_t sap
, void *destp
, size_t destlen
, bool checkaf
)
248 struct sockaddr
*sa
= (struct sockaddr
*)sap
;
249 struct sockaddr_dl
*sdl
;
250 uint8_t *dest
= destp
;
251 size_t tlen
, copylen
;
253 #ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
254 copylen
= sa
->sa_len
;
255 tlen
= (copylen
== 0) ? sizeof(ROUNDUP_TYPE
) : ROUNDUP(copylen
);
256 #else /* !HAVE_STRUCT_SOCKADDR_SA_LEN */
257 copylen
= tlen
= SAROUNDUP(sap
);
258 #endif /* !HAVE_STRUCT_SOCKADDR_SA_LEN */
260 if (copylen
> 0 && dest
!= NULL
) {
261 if (checkaf
&& af_check(sa
->sa_family
) == 0)
264 * Handle sockaddr_dl corner case:
265 * RTA_NETMASK might be AF_LINK, but it doesn't anything
266 * relevant (e.g. zeroed out fields). Check for this
267 * case and avoid warning log message.
269 if (sa
->sa_family
== AF_LINK
) {
270 sdl
= (struct sockaddr_dl
*)sa
;
271 if (sdl
->sdl_index
== 0 || sdl
->sdl_nlen
== 0)
275 if (copylen
> destlen
) {
277 "%s: destination buffer too small (%zu vs %zu)",
278 __func__
, copylen
, destlen
);
279 memcpy(dest
, sap
, destlen
);
281 memcpy(dest
, sap
, copylen
);
287 size_t rta_get(caddr_t sap
, void *destp
, size_t destlen
)
289 return _rta_get(sap
, destp
, destlen
, true);
292 size_t rta_getattr(caddr_t sap
, void *destp
, size_t destlen
)
294 return _rta_get(sap
, destp
, destlen
, false);
297 size_t rta_getsdlname(caddr_t sap
, void *destp
, short *destlen
)
299 struct sockaddr_dl
*sdl
= (struct sockaddr_dl
*)sap
;
300 uint8_t *dest
= destp
;
301 size_t tlen
, copylen
;
303 copylen
= sdl
->sdl_nlen
;
304 #ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
305 struct sockaddr
*sa
= (struct sockaddr
*)sap
;
307 tlen
= (sa
->sa_len
== 0) ? sizeof(ROUNDUP_TYPE
) : ROUNDUP(sa
->sa_len
);
308 #else /* !HAVE_STRUCT_SOCKADDR_SA_LEN */
309 tlen
= SAROUNDUP(sap
);
310 #endif /* !HAVE_STRUCT_SOCKADDR_SA_LEN */
312 if (copylen
> 0 && dest
!= NULL
&& sdl
->sdl_family
== AF_LINK
) {
313 if (copylen
> IFNAMSIZ
) {
315 "%s: destination buffer too small (%zu vs %d)",
316 __func__
, copylen
, IFNAMSIZ
);
317 memcpy(dest
, sdl
->sdl_data
, IFNAMSIZ
);
321 memcpy(dest
, sdl
->sdl_data
, copylen
);
331 const char *rtatostr(unsigned int flags
, char *buf
, size_t buflen
)
333 const char *flagstr
, *bufstart
;
337 /* Hold the pointer to the buffer beginning. */
340 for (bit
= 1; bit
; bit
<<= 1) {
341 if ((flags
& bit
) == 0)
358 #endif /* RTA_GENMASK */
369 #endif /* RTA_AUTHOR */
382 #endif /* RTA_SRCMASK */
387 #endif /* RTA_LABEL */
390 snprintf(ustr
, sizeof(ustr
), "0x%x", bit
);
395 wlen
= snprintf(buf
, buflen
, "%s,", flagstr
);
400 /* Check for empty buffer. */
404 /* Remove the last comma. */
410 /* Dump routing table flag for debug purpose. */
411 static void rtm_flag_dump(int flag
)
413 const struct message
*mes
;
414 static char buf
[BUFSIZ
];
417 for (mes
= rtm_flag_str
; mes
->key
!= 0; mes
++) {
418 if (mes
->key
& flag
) {
419 strlcat(buf
, mes
->str
, BUFSIZ
);
420 strlcat(buf
, " ", BUFSIZ
);
423 zlog_debug("Kernel: %s", buf
);
426 #ifdef RTM_IFANNOUNCE
427 /* Interface adding function */
428 static int ifan_read(struct if_announcemsghdr
*ifan
)
430 struct interface
*ifp
;
432 ifp
= if_lookup_by_index(ifan
->ifan_index
, VRF_DEFAULT
);
435 assert((ifp
->ifindex
== ifan
->ifan_index
)
436 || (ifp
->ifindex
== IFINDEX_INTERNAL
));
438 if ((ifp
== NULL
) || ((ifp
->ifindex
== IFINDEX_INTERNAL
)
439 && (ifan
->ifan_what
== IFAN_ARRIVAL
))) {
440 if (IS_ZEBRA_DEBUG_KERNEL
)
442 "%s: creating interface for ifindex %d, name %s",
443 __func__
, ifan
->ifan_index
, ifan
->ifan_name
);
445 /* Create Interface */
446 ifp
= if_get_by_name(ifan
->ifan_name
, VRF_DEFAULT
,
448 if_set_index(ifp
, ifan
->ifan_index
);
452 } else if (ifp
!= NULL
&& ifan
->ifan_what
== IFAN_DEPARTURE
)
453 if_delete_update(ifp
);
459 if (IS_ZEBRA_DEBUG_KERNEL
)
460 zlog_debug("%s: interface %s index %d", __func__
,
461 ifan
->ifan_name
, ifan
->ifan_index
);
465 #endif /* RTM_IFANNOUNCE */
467 #ifdef HAVE_BSD_IFI_LINK_STATE
468 /* BSD link detect translation */
469 static void bsd_linkdetect_translate(struct if_msghdr
*ifm
)
471 if ((ifm
->ifm_data
.ifi_link_state
>= LINK_STATE_UP
)
472 || (ifm
->ifm_data
.ifi_link_state
== LINK_STATE_UNKNOWN
))
473 SET_FLAG(ifm
->ifm_flags
, IFF_RUNNING
);
475 UNSET_FLAG(ifm
->ifm_flags
, IFF_RUNNING
);
477 #endif /* HAVE_BSD_IFI_LINK_STATE */
479 static enum zebra_link_type
sdl_to_zebra_link_type(unsigned int sdlt
)
483 return ZEBRA_LLT_ETHER
;
485 return ZEBRA_LLT_X25
;
487 return ZEBRA_LLT_FDDI
;
489 return ZEBRA_LLT_PPP
;
491 return ZEBRA_LLT_LOOPBACK
;
493 return ZEBRA_LLT_SLIP
;
495 return ZEBRA_LLT_ARCNET
;
497 return ZEBRA_LLT_ATM
;
499 return ZEBRA_LLT_LOCALTLK
;
501 return ZEBRA_LLT_HIPPI
;
504 return ZEBRA_LLT_IEEE1394
;
508 return ZEBRA_LLT_UNKNOWN
;
513 * Handle struct if_msghdr obtained from reading routing socket or
514 * sysctl (from interface_list). There may or may not be sockaddrs
515 * present after the header.
517 int ifm_read(struct if_msghdr
*ifm
)
519 struct interface
*ifp
= NULL
;
520 struct sockaddr_dl
*sdl
= NULL
;
521 char ifname
[IFNAMSIZ
];
527 /* terminate ifname at head (for strnlen) and tail (for safety) */
528 ifname
[IFNAMSIZ
- 1] = '\0';
530 /* paranoia: sanity check structure */
531 if (ifm
->ifm_msglen
< sizeof(struct if_msghdr
)) {
532 flog_err(EC_ZEBRA_NETLINK_LENGTH_ERROR
,
533 "ifm_read: ifm->ifm_msglen %d too short",
539 * Check for a sockaddr_dl following the message. First, point to
540 * where a socakddr might be if one follows the message.
542 cp
= (void *)(ifm
+ 1);
544 /* Look up for RTA_IFP and skip others. */
545 for (maskbit
= 1; maskbit
; maskbit
<<= 1) {
546 if ((maskbit
& ifm
->ifm_addrs
) == 0)
548 if (maskbit
!= RTA_IFP
) {
549 cp
+= rta_get(cp
, NULL
, 0);
553 /* Save the pointer to the structure. */
554 sdl
= (struct sockaddr_dl
*)cp
;
555 cp
+= rta_getsdlname(cp
, ifname
, &ifnlen
);
558 if (IS_ZEBRA_DEBUG_KERNEL
)
559 zlog_debug("%s: sdl ifname %s addrs {%s}", __func__
,
560 (ifnlen
? ifname
: "(nil)"),
561 rtatostr(ifm
->ifm_addrs
, fbuf
, sizeof(fbuf
)));
564 * Look up on ifindex first, because ifindices are the primary handle
566 * interfaces across the user/kernel boundary, for most systems. (Some
567 * messages, such as up/down status changes on NetBSD, do not include a
570 if ((ifp
= if_lookup_by_index(ifm
->ifm_index
, VRF_DEFAULT
)) != NULL
) {
571 /* we have an ifp, verify that the name matches as some systems,
572 * eg Solaris, have a 1:many association of ifindex:ifname
573 * if they dont match, we dont have the correct ifp and should
574 * set it back to NULL to let next check do lookup by name
576 if (ifnlen
&& (strncmp(ifp
->name
, ifname
, IFNAMSIZ
) != 0)) {
577 if (IS_ZEBRA_DEBUG_KERNEL
)
579 "%s: ifp name %s doesn't match sdl name %s",
580 __func__
, ifp
->name
, ifname
);
586 * If we dont have an ifp, try looking up by name. Particularly as some
587 * systems (Solaris) have a 1:many mapping of ifindex:ifname - the
589 * is therefore our unique handle to that interface.
591 * Interfaces specified in the configuration file for which the ifindex
592 * has not been determined will have ifindex == IFINDEX_INTERNAL, and
594 * interfaces are found by this search, and then their ifindex values
598 if ((ifp
== NULL
) && ifnlen
)
599 ifp
= if_lookup_by_name(ifname
, VRF_DEFAULT
);
602 * If ifp still does not exist or has an invalid index
603 * (IFINDEX_INTERNAL),
604 * create or fill in an interface.
606 if ((ifp
== NULL
) || (ifp
->ifindex
== IFINDEX_INTERNAL
)) {
608 * To create or fill in an interface, a sockaddr_dl (via
609 * RTA_IFP) is required.
612 zlog_debug("Interface index %d (new) missing ifname",
617 #ifndef RTM_IFANNOUNCE
618 /* Down->Down interface should be ignored here.
619 * See further comment below.
621 if (!CHECK_FLAG(ifm
->ifm_flags
, IFF_UP
))
623 #endif /* !RTM_IFANNOUNCE */
626 /* Interface that zebra was not previously aware of, so
628 ifp
= if_get_by_name(ifname
, VRF_DEFAULT
,
630 if (IS_ZEBRA_DEBUG_KERNEL
)
631 zlog_debug("%s: creating ifp for ifindex %d",
632 __func__
, ifm
->ifm_index
);
635 if (IS_ZEBRA_DEBUG_KERNEL
)
637 "%s: updated/created ifp, ifname %s, ifindex %d",
638 __func__
, ifp
->name
, ifp
->ifindex
);
640 * Fill in newly created interface structure, or larval
641 * structure with ifindex IFINDEX_INTERNAL.
643 if_set_index(ifp
, ifm
->ifm_index
);
645 #ifdef HAVE_BSD_IFI_LINK_STATE /* translate BSD kernel msg for link-state */
646 bsd_linkdetect_translate(ifm
);
647 #endif /* HAVE_BSD_IFI_LINK_STATE */
649 if_flags_update(ifp
, ifm
->ifm_flags
);
650 #if defined(__bsdi__)
654 #endif /* __bsdi__ */
658 * XXX sockaddr_dl contents can be larger than the structure
659 * definition. There are 2 big families here:
660 * - BSD has sdl_len + sdl_data[16] + overruns sdl_data
661 * we MUST use sdl_len here or we'll truncate data.
662 * - Solaris has no sdl_len, but sdl_data[244]
663 * presumably, it's not going to run past that, so sizeof()
665 * a nonzero ifnlen from rta_getsdlname() means sdl is valid
667 ifp
->ll_type
= ZEBRA_LLT_UNKNOWN
;
668 ifp
->hw_addr_len
= 0;
670 #ifdef HAVE_STRUCT_SOCKADDR_DL_SDL_LEN
671 memcpy(&((struct zebra_if
*)ifp
->info
)->sdl
, sdl
,
674 memcpy(&((struct zebra_if
*)ifp
->info
)->sdl
, sdl
,
675 sizeof(struct sockaddr_dl
));
676 #endif /* HAVE_STRUCT_SOCKADDR_DL_SDL_LEN */
678 ifp
->ll_type
= sdl_to_zebra_link_type(sdl
->sdl_type
);
679 if (sdl
->sdl_alen
<= sizeof(ifp
->hw_addr
)) {
680 memcpy(ifp
->hw_addr
, LLADDR(sdl
),
682 ifp
->hw_addr_len
= sdl
->sdl_alen
;
689 * Interface structure exists. Adjust stored flags from
690 * notification. If interface has up->down or down->up
691 * transition, call state change routines (to adjust routes,
692 * notify routing daemons, etc.). (Other flag changes are stored
693 * but apparently do not trigger action.)
696 if (ifp
->ifindex
!= ifm
->ifm_index
) {
698 "%s: index mismatch, ifname %s, ifp index %d, ifm index %d",
699 __func__
, ifp
->name
, ifp
->ifindex
,
704 #ifdef HAVE_BSD_IFI_LINK_STATE /* translate BSD kernel msg for link-state */
705 bsd_linkdetect_translate(ifm
);
706 #endif /* HAVE_BSD_IFI_LINK_STATE */
708 /* update flags and handle operative->inoperative transition, if
710 if_flags_update(ifp
, ifm
->ifm_flags
);
712 #ifndef RTM_IFANNOUNCE
713 if (!if_is_up(ifp
)) {
714 /* No RTM_IFANNOUNCE on this platform, so we can never
715 * distinguish between ~IFF_UP and delete. We must
717 * it has been deleted.
718 * Eg, Solaris will not notify us of unplumb.
720 * XXX: Fixme - this should be runtime detected
721 * So that a binary compiled on a system with IFANNOUNCE
722 * will still behave correctly if run on a platform
725 if_delete_update(ifp
);
727 #endif /* RTM_IFANNOUNCE */
729 #if defined(__bsdi__)
733 #endif /* __bsdi__ */
738 #ifdef HAVE_NET_RT_IFLIST
739 ifp
->stats
= ifm
->ifm_data
;
740 #endif /* HAVE_NET_RT_IFLIST */
741 ifp
->speed
= ifm
->ifm_data
.ifi_baudrate
/ 1000000;
743 if (IS_ZEBRA_DEBUG_KERNEL
)
744 zlog_debug("%s: interface %s index %d", __func__
, ifp
->name
,
750 /* Address read from struct ifa_msghdr. */
751 static void ifam_read_mesg(struct ifa_msghdr
*ifm
, union sockunion
*addr
,
752 union sockunion
*mask
, union sockunion
*brd
,
753 char *ifname
, short *ifnlen
)
757 union sockunion gateway
;
761 pnt
= (caddr_t
)(ifm
+ 1);
762 end
= ((caddr_t
)ifm
) + ifm
->ifam_msglen
;
764 /* Be sure structure is cleared */
765 memset(mask
, 0, sizeof(union sockunion
));
766 memset(addr
, 0, sizeof(union sockunion
));
767 memset(brd
, 0, sizeof(union sockunion
));
768 memset(&dst
, 0, sizeof(union sockunion
));
769 memset(&gateway
, 0, sizeof(union sockunion
));
771 /* We fetch each socket variable into sockunion. */
772 for (maskbit
= 1; maskbit
; maskbit
<<= 1) {
773 if ((maskbit
& ifm
->ifam_addrs
) == 0)
778 pnt
+= rta_get(pnt
, &dst
, sizeof(dst
));
781 pnt
+= rta_get(pnt
, &gateway
, sizeof(gateway
));
784 pnt
+= rta_getattr(pnt
, mask
, sizeof(*mask
));
787 pnt
+= rta_getsdlname(pnt
, ifname
, ifnlen
);
790 pnt
+= rta_get(pnt
, addr
, sizeof(*addr
));
793 pnt
+= rta_get(pnt
, brd
, sizeof(*brd
));
797 pnt
+= rta_get(pnt
, NULL
, 0);
802 zlog_warn("%s: overflow detected (pnt:%p end:%p)",
808 if (IS_ZEBRA_DEBUG_KERNEL
) {
809 switch (sockunion_family(addr
)) {
813 (sockunion_family(addr
) == AF_INET
)
814 ? ip_masklen(mask
->sin
.sin_addr
)
815 : ip6_masklen(mask
->sin6
.sin6_addr
);
817 "%s: ifindex %d, ifname %s, ifam_addrs {%s}, ifam_flags 0x%x, addr %pSU/%d broad %pSU dst %pSU gateway %pSU",
818 __func__
, ifm
->ifam_index
,
819 (ifnlen
? ifname
: "(nil)"),
820 rtatostr(ifm
->ifam_addrs
, fbuf
, sizeof(fbuf
)),
821 ifm
->ifam_flags
, addr
, masklen
, brd
, &dst
,
825 zlog_debug("%s: ifindex %d, ifname %s, ifam_addrs {%s}",
826 __func__
, ifm
->ifam_index
,
827 (ifnlen
? ifname
: "(nil)"),
828 rtatostr(ifm
->ifam_addrs
, fbuf
,
834 /* Assert read up end point matches to end point */
835 pnt
= (caddr_t
)ROUNDUP((size_t)pnt
);
836 if (pnt
!= (caddr_t
)ROUNDUP((size_t)end
))
837 zlog_debug("ifam_read() doesn't read all socket data");
840 /* Interface's address information get. */
841 int ifam_read(struct ifa_msghdr
*ifam
)
843 struct interface
*ifp
= NULL
;
844 union sockunion addr
, mask
, brd
;
845 bool dest_same
= false;
846 char ifname
[INTERFACE_NAMSIZ
];
848 bool isalias
= false;
851 ifname
[0] = ifname
[INTERFACE_NAMSIZ
- 1] = '\0';
853 /* Allocate and read address information. */
854 ifam_read_mesg(ifam
, &addr
, &mask
, &brd
, ifname
, &ifnlen
);
856 if ((ifp
= if_lookup_by_index(ifam
->ifam_index
, VRF_DEFAULT
)) == NULL
) {
857 flog_warn(EC_ZEBRA_UNKNOWN_INTERFACE
,
858 "%s: no interface for ifname %s, index %d", __func__
,
859 ifname
, ifam
->ifam_index
);
863 if (ifnlen
&& strncmp(ifp
->name
, ifname
, INTERFACE_NAMSIZ
))
867 * Mark the alias prefixes as secondary
870 SET_FLAG(flags
, ZEBRA_IFA_SECONDARY
);
872 /* N.B. The info in ifa_msghdr does not tell us whether the RTA_BRD
873 field contains a broadcast address or a peer address, so we are
875 rely upon the interface type. */
876 if (if_is_pointopoint(ifp
))
877 SET_FLAG(flags
, ZEBRA_IFA_PEER
);
879 if (memcmp(&addr
, &brd
, sizeof(addr
)) == 0)
884 /* it might seem cute to grab the interface metric here, however
885 * we're processing an address update message, and so some systems
886 * (e.g. FBSD) dont bother to fill in ifam_metric. Disabled, but left
887 * in deliberately, as comment.
889 ifp
->metric
= ifam
->ifam_metric
;
892 /* Add connected address. */
893 switch (sockunion_family(&addr
)) {
895 if (ifam
->ifam_type
== RTM_NEWADDR
)
896 connected_add_ipv4(ifp
, flags
, &addr
.sin
.sin_addr
,
897 ip_masklen(mask
.sin
.sin_addr
),
898 dest_same
? NULL
: &brd
.sin
.sin_addr
,
899 (isalias
? ifname
: NULL
),
902 connected_delete_ipv4(ifp
, flags
, &addr
.sin
.sin_addr
,
903 ip_masklen(mask
.sin
.sin_addr
),
905 : &brd
.sin
.sin_addr
);
908 /* Unset interface index from link-local address when IPv6 stack
910 if (IN6_IS_ADDR_LINKLOCAL(&addr
.sin6
.sin6_addr
)) {
911 SET_IN6_LINKLOCAL_IFINDEX(addr
.sin6
.sin6_addr
, 0);
914 if (ifam
->ifam_type
== RTM_NEWADDR
)
915 connected_add_ipv6(ifp
, flags
, &addr
.sin6
.sin6_addr
,
917 ip6_masklen(mask
.sin6
.sin6_addr
),
918 (isalias
? ifname
: NULL
),
921 connected_delete_ipv6(ifp
, &addr
.sin6
.sin6_addr
, NULL
,
922 ip6_masklen(mask
.sin6
.sin6_addr
));
925 /* Unsupported family silently ignore... */
929 /* Check interface flag for implicit up of the interface. */
935 /* Interface function for reading kernel routing table information. */
936 static int rtm_read_mesg(struct rt_msghdr
*rtm
, union sockunion
*dest
,
937 union sockunion
*mask
, union sockunion
*gate
,
938 char *ifname
, short *ifnlen
)
943 /* Pnt points out socket data start point. */
944 pnt
= (caddr_t
)(rtm
+ 1);
945 end
= ((caddr_t
)rtm
) + rtm
->rtm_msglen
;
947 /* rt_msghdr version check. */
948 if (rtm
->rtm_version
!= RTM_VERSION
)
949 flog_warn(EC_ZEBRA_RTM_VERSION_MISMATCH
,
950 "Routing message version different %d should be %d.This may cause problem",
951 rtm
->rtm_version
, RTM_VERSION
);
953 /* Be sure structure is cleared */
954 memset(dest
, 0, sizeof(union sockunion
));
955 memset(gate
, 0, sizeof(union sockunion
));
956 memset(mask
, 0, sizeof(union sockunion
));
958 /* We fetch each socket variable into sockunion. */
959 /* We fetch each socket variable into sockunion. */
960 for (maskbit
= 1; maskbit
; maskbit
<<= 1) {
961 if ((maskbit
& rtm
->rtm_addrs
) == 0)
966 pnt
+= rta_get(pnt
, dest
, sizeof(*dest
));
969 pnt
+= rta_get(pnt
, gate
, sizeof(*gate
));
972 pnt
+= rta_getattr(pnt
, mask
, sizeof(*mask
));
975 pnt
+= rta_getsdlname(pnt
, ifname
, ifnlen
);
979 pnt
+= rta_get(pnt
, NULL
, 0);
984 zlog_warn("%s: overflow detected (pnt:%p end:%p)",
990 /* If there is netmask information set it's family same as
992 if (rtm
->rtm_addrs
& RTA_NETMASK
)
993 mask
->sa
.sa_family
= dest
->sa
.sa_family
;
995 /* Assert read up to the end of pointer. */
997 zlog_debug("rtm_read() doesn't read all socket data.");
999 return rtm
->rtm_flags
;
1002 void rtm_read(struct rt_msghdr
*rtm
)
1005 uint32_t zebra_flags
;
1006 union sockunion dest
, mask
, gate
;
1007 char ifname
[INTERFACE_NAMSIZ
+ 1];
1011 ifindex_t ifindex
= 0;
1017 /* Read destination and netmask and gateway from rtm message
1019 flags
= rtm_read_mesg(rtm
, &dest
, &mask
, &gate
, ifname
, &ifnlen
);
1020 if (!(flags
& RTF_DONE
))
1022 if (IS_ZEBRA_DEBUG_KERNEL
)
1023 zlog_debug("%s: got rtm of type %d (%s) addrs {%s}", __func__
,
1025 lookup_msg(rtm_type_str
, rtm
->rtm_type
, NULL
),
1026 rtatostr(rtm
->rtm_addrs
, fbuf
, sizeof(fbuf
)));
1028 #ifdef RTF_CLONED /*bsdi, netbsd 1.6*/
1029 if (flags
& RTF_CLONED
)
1032 #ifdef RTF_WASCLONED /*freebsd*/
1033 if (flags
& RTF_WASCLONED
)
1037 if ((rtm
->rtm_type
== RTM_ADD
|| rtm
->rtm_type
== RTM_CHANGE
)
1038 && !(flags
& RTF_UP
))
1041 /* This is connected route. */
1042 if (!(flags
& RTF_GATEWAY
))
1045 if (flags
& RTF_PROTO1
)
1046 SET_FLAG(zebra_flags
, ZEBRA_FLAG_SELFROUTE
);
1048 memset(&nh
, 0, sizeof(nh
));
1050 nh
.vrf_id
= VRF_DEFAULT
;
1051 /* This is a reject or blackhole route */
1052 if (flags
& RTF_REJECT
) {
1053 nh
.type
= NEXTHOP_TYPE_BLACKHOLE
;
1054 nh
.bh_type
= BLACKHOLE_REJECT
;
1055 } else if (flags
& RTF_BLACKHOLE
) {
1056 nh
.type
= NEXTHOP_TYPE_BLACKHOLE
;
1057 nh
.bh_type
= BLACKHOLE_NULL
;
1061 * Ignore our own messages.
1063 if (rtm
->rtm_type
!= RTM_GET
&& rtm
->rtm_pid
== pid
)
1066 if (dest
.sa
.sa_family
== AF_INET
) {
1069 p
.u
.prefix4
= dest
.sin
.sin_addr
;
1070 if (flags
& RTF_HOST
)
1071 p
.prefixlen
= IPV4_MAX_BITLEN
;
1073 p
.prefixlen
= ip_masklen(mask
.sin
.sin_addr
);
1076 nh
.type
= NEXTHOP_TYPE_IPV4
;
1077 nh
.gate
.ipv4
= gate
.sin
.sin_addr
;
1079 } else if (dest
.sa
.sa_family
== AF_INET6
) {
1081 p
.family
= AF_INET6
;
1082 p
.u
.prefix6
= dest
.sin6
.sin6_addr
;
1083 if (flags
& RTF_HOST
)
1084 p
.prefixlen
= IPV6_MAX_BITLEN
;
1086 p
.prefixlen
= ip6_masklen(mask
.sin6
.sin6_addr
);
1089 if (IN6_IS_ADDR_LINKLOCAL(&gate
.sin6
.sin6_addr
)) {
1090 ifindex
= IN6_LINKLOCAL_IFINDEX(gate
.sin6
.sin6_addr
);
1091 SET_IN6_LINKLOCAL_IFINDEX(gate
.sin6
.sin6_addr
, 0);
1096 nh
.type
= ifindex
? NEXTHOP_TYPE_IPV6_IFINDEX
1097 : NEXTHOP_TYPE_IPV6
;
1098 nh
.gate
.ipv6
= gate
.sin6
.sin6_addr
;
1099 nh
.ifindex
= ifindex
;
1105 * CHANGE: delete the old prefix, we have no further information
1106 * to specify the route really
1108 if (rtm
->rtm_type
== RTM_CHANGE
)
1109 rib_delete(afi
, SAFI_UNICAST
, VRF_DEFAULT
, ZEBRA_ROUTE_KERNEL
,
1110 0, zebra_flags
, &p
, NULL
, NULL
, 0, RT_TABLE_MAIN
, 0,
1112 if (rtm
->rtm_type
== RTM_GET
|| rtm
->rtm_type
== RTM_ADD
1113 || rtm
->rtm_type
== RTM_CHANGE
)
1114 rib_add(afi
, SAFI_UNICAST
, VRF_DEFAULT
, ZEBRA_ROUTE_KERNEL
, 0,
1115 zebra_flags
, &p
, NULL
, &nh
, 0, RT_TABLE_MAIN
,
1118 rib_delete(afi
, SAFI_UNICAST
, VRF_DEFAULT
, ZEBRA_ROUTE_KERNEL
,
1119 0, zebra_flags
, &p
, NULL
, &nh
, 0, RT_TABLE_MAIN
, 0,
1123 /* Interface function for the kernel routing table updates. Support
1124 * for RTM_CHANGE will be needed.
1125 * Exported only for rt_socket.c
1127 int rtm_write(int message
, union sockunion
*dest
, union sockunion
*mask
,
1128 union sockunion
*gate
, union sockunion
*mpls
, unsigned int index
,
1129 enum blackhole_type bh_type
, int metric
)
1133 struct interface
*ifp
;
1135 /* Sequencial number of routing message. */
1136 static int msg_seq
= 0;
1138 /* Struct of rt_msghdr and buffer for storing socket's data. */
1140 struct rt_msghdr rtm
;
1144 if (dplane_routing_sock
< 0)
1145 return ZEBRA_ERR_EPERM
;
1147 /* Clear and set rt_msghdr values */
1148 memset(&msg
, 0, sizeof(struct rt_msghdr
));
1149 msg
.rtm
.rtm_version
= RTM_VERSION
;
1150 msg
.rtm
.rtm_type
= message
;
1151 msg
.rtm
.rtm_seq
= msg_seq
++;
1152 msg
.rtm
.rtm_addrs
= RTA_DST
;
1153 msg
.rtm
.rtm_addrs
|= RTA_GATEWAY
;
1154 msg
.rtm
.rtm_flags
= RTF_UP
;
1156 msg
.rtm
.rtm_flags
|= RTF_MPATH
;
1157 msg
.rtm
.rtm_fmask
= RTF_MPLS
;
1159 msg
.rtm
.rtm_index
= index
;
1162 msg
.rtm
.rtm_rmx
.rmx_hopcount
= metric
;
1163 msg
.rtm
.rtm_inits
|= RTV_HOPCOUNT
;
1166 ifp
= if_lookup_by_index(index
, VRF_DEFAULT
);
1168 if (gate
&& (message
== RTM_ADD
|| message
== RTM_CHANGE
))
1169 msg
.rtm
.rtm_flags
|= RTF_GATEWAY
;
1171 /* When RTF_CLONING is unavailable on BSD, should we set some
1172 * other flag instead?
1175 if (!gate
&& (message
== RTM_ADD
|| message
== RTM_CHANGE
) && ifp
1176 && (ifp
->flags
& IFF_POINTOPOINT
) == 0)
1177 msg
.rtm
.rtm_flags
|= RTF_CLONING
;
1178 #endif /* RTF_CLONING */
1180 /* If no protocol specific gateway is specified, use link
1181 address for gateway. */
1184 char dest_buf
[INET_ADDRSTRLEN
] = "NULL",
1185 mask_buf
[INET_ADDRSTRLEN
] = "255.255.255.255";
1187 inet_ntop(AF_INET
, &dest
->sin
.sin_addr
,
1188 dest_buf
, INET_ADDRSTRLEN
);
1190 inet_ntop(AF_INET
, &mask
->sin
.sin_addr
,
1191 mask_buf
, INET_ADDRSTRLEN
);
1193 EC_ZEBRA_RTM_NO_GATEWAY
,
1194 "%s: %s/%s: gate == NULL and no gateway found for ifindex %d",
1195 __func__
, dest_buf
, mask_buf
, index
);
1198 gate
= (union sockunion
*)&((struct zebra_if
*)ifp
->info
)->sdl
;
1202 msg
.rtm
.rtm_addrs
|= RTA_NETMASK
;
1203 else if (message
== RTM_ADD
|| message
== RTM_CHANGE
)
1204 msg
.rtm
.rtm_flags
|= RTF_HOST
;
1208 msg
.rtm
.rtm_addrs
|= RTA_SRC
;
1209 msg
.rtm
.rtm_flags
|= RTF_MPLS
;
1211 if (mpls
->smpls
.smpls_label
1212 != htonl(MPLS_LABEL_IMPLICIT_NULL
<< MPLS_LABEL_OFFSET
))
1213 msg
.rtm
.rtm_mpls
= MPLS_OP_PUSH
;
1217 /* Tagging route with flags */
1218 msg
.rtm
.rtm_flags
|= (RTF_PROTO1
);
1221 case BLACKHOLE_UNSPEC
:
1223 case BLACKHOLE_REJECT
:
1224 msg
.rtm
.rtm_flags
|= RTF_REJECT
;
1227 msg
.rtm
.rtm_flags
|= RTF_BLACKHOLE
;
1232 #define SOCKADDRSET(X, R) \
1233 if (msg.rtm.rtm_addrs & (R)) { \
1234 int len = SAROUNDUP(X); \
1235 memcpy(pnt, (caddr_t)(X), len); \
1239 pnt
= (caddr_t
)msg
.buf
;
1241 /* Write each socket data into rtm message buffer */
1242 SOCKADDRSET(dest
, RTA_DST
);
1243 SOCKADDRSET(gate
, RTA_GATEWAY
);
1244 SOCKADDRSET(mask
, RTA_NETMASK
);
1246 SOCKADDRSET(mpls
, RTA_SRC
);
1249 msg
.rtm
.rtm_msglen
= pnt
- (caddr_t
)&msg
;
1251 ret
= write(dplane_routing_sock
, &msg
, msg
.rtm
.rtm_msglen
);
1253 if (ret
!= msg
.rtm
.rtm_msglen
) {
1254 if (errno
== EEXIST
)
1255 return ZEBRA_ERR_RTEXIST
;
1256 if (errno
== ENETUNREACH
)
1257 return ZEBRA_ERR_RTUNREACH
;
1259 return ZEBRA_ERR_RTNOEXIST
;
1261 flog_err_sys(EC_LIB_SOCKET
, "%s: write : %s (%d)", __func__
,
1262 safe_strerror(errno
), errno
);
1263 return ZEBRA_ERR_KERNEL
;
1265 return ZEBRA_ERR_NOERROR
;
1270 #include "zebra/zserv.h"
1272 /* For debug purpose. */
1273 static void rtmsg_debug(struct rt_msghdr
*rtm
)
1277 zlog_debug("Kernel: Len: %d Type: %s", rtm
->rtm_msglen
,
1278 lookup_msg(rtm_type_str
, rtm
->rtm_type
, NULL
));
1279 rtm_flag_dump(rtm
->rtm_flags
);
1280 zlog_debug("Kernel: message seq %d", rtm
->rtm_seq
);
1281 zlog_debug("Kernel: pid %lld, rtm_addrs {%s}", (long long)rtm
->rtm_pid
,
1282 rtatostr(rtm
->rtm_addrs
, fbuf
, sizeof(fbuf
)));
1285 /* This is pretty gross, better suggestions welcome -- mhandler */
1288 #define RTAX_MAX RTA_NUMBITS
1291 #endif /* RTA_NUMBITS */
1292 #endif /* RTAX_MAX */
1294 /* Kernel routing table and interface updates via routing socket. */
1295 static int kernel_read(struct thread
*thread
)
1299 struct rt_msghdr
*rtm
;
1302 * This must be big enough for any message the kernel might send.
1303 * Rather than determining how many sockaddrs of what size might be
1304 * in each particular message, just use RTAX_MAX of sockaddr_storage
1305 * for each. Note that the sockaddrs must be after each message
1306 * definition, or rather after whichever happens to be the largest,
1307 * since the buffer needs to be big enough for a message and the
1308 * sockaddrs together.
1311 /* Routing information. */
1313 struct rt_msghdr rtm
;
1314 struct sockaddr_storage addr
[RTAX_MAX
];
1317 /* Interface information. */
1319 struct if_msghdr ifm
;
1320 struct sockaddr_storage addr
[RTAX_MAX
];
1323 /* Interface address information. */
1325 struct ifa_msghdr ifa
;
1326 struct sockaddr_storage addr
[RTAX_MAX
];
1329 #ifdef RTM_IFANNOUNCE
1330 /* Interface arrival/departure */
1332 struct if_announcemsghdr ifan
;
1333 struct sockaddr_storage addr
[RTAX_MAX
];
1335 #endif /* RTM_IFANNOUNCE */
1339 /* Fetch routing socket. */
1340 sock
= THREAD_FD(thread
);
1342 nbytes
= read(sock
, &buf
, sizeof(buf
));
1345 if (errno
== ENOBUFS
) {
1346 flog_err(EC_ZEBRA_RECVMSG_OVERRUN
,
1347 "routing socket overrun: %s",
1348 safe_strerror(errno
));
1350 * In this case we are screwed.
1351 * There is no good way to
1352 * recover zebra at this point.
1356 if (errno
!= EAGAIN
&& errno
!= EWOULDBLOCK
)
1357 flog_err_sys(EC_LIB_SOCKET
, "routing socket error: %s",
1358 safe_strerror(errno
));
1365 thread_add_read(zrouter
.master
, kernel_read
, NULL
, sock
, NULL
);
1367 if (IS_ZEBRA_DEBUG_KERNEL
)
1368 rtmsg_debug(&buf
.r
.rtm
);
1373 * Ensure that we didn't drop any data, so that processing routines
1374 * can assume they have the whole message.
1376 if (rtm
->rtm_msglen
!= nbytes
) {
1378 "kernel_read: rtm->rtm_msglen %d, nbytes %d, type %d",
1379 rtm
->rtm_msglen
, nbytes
, rtm
->rtm_type
);
1383 switch (rtm
->rtm_type
) {
1390 ifm_read(&buf
.im
.ifm
);
1394 ifam_read(&buf
.ia
.ifa
);
1396 #ifdef RTM_IFANNOUNCE
1397 case RTM_IFANNOUNCE
:
1398 ifan_read(&buf
.ian
.ifan
);
1400 #endif /* RTM_IFANNOUNCE */
1402 if (IS_ZEBRA_DEBUG_KERNEL
)
1403 zlog_debug("Unprocessed RTM_type: %d", rtm
->rtm_type
);
1409 /* Make routing socket. */
1410 static void routing_socket(struct zebra_ns
*zns
)
1412 frr_with_privs(&zserv_privs
) {
1413 routing_sock
= ns_socket(AF_ROUTE
, SOCK_RAW
, 0, zns
->ns_id
);
1415 dplane_routing_sock
=
1416 ns_socket(AF_ROUTE
, SOCK_RAW
, 0, zns
->ns_id
);
1419 if (routing_sock
< 0) {
1420 flog_err_sys(EC_LIB_SOCKET
, "Can't init kernel routing socket");
1424 if (dplane_routing_sock
< 0) {
1425 flog_err_sys(EC_LIB_SOCKET
,
1426 "Can't init kernel dataplane routing socket");
1431 /* Allow reporting of route(4) buffer overflow errors */
1434 if (setsockopt(routing_sock
, SOL_SOCKET
, SO_RERROR
, &n
, sizeof(n
)) < 0)
1435 flog_err_sys(EC_LIB_SOCKET
,
1436 "Can't set SO_RERROR on routing socket");
1439 /* XXX: Socket should be NONBLOCK, however as we currently
1440 * discard failed writes, this will lead to inconsistencies.
1441 * For now, socket must be blocking.
1443 /*if (fcntl (routing_sock, F_SETFL, O_NONBLOCK) < 0)
1444 zlog_warn ("Can't set O_NONBLOCK to routing socket");*/
1446 /* kernel_read needs rewrite. */
1447 thread_add_read(zrouter
.master
, kernel_read
, NULL
, routing_sock
, NULL
);
1450 /* Exported interface function. This function simply calls
1451 routing_socket (). */
1452 void kernel_init(struct zebra_ns
*zns
)
1454 routing_socket(zns
);
1457 void kernel_terminate(struct zebra_ns
*zns
, bool complete
)
1463 * Called by the dplane pthread to read incoming OS messages and dispatch them.
1465 int kernel_dplane_read(struct zebra_dplane_info
*info
)
1470 void kernel_update_multi(struct dplane_ctx_q
*ctx_list
)
1472 struct zebra_dplane_ctx
*ctx
;
1473 struct dplane_ctx_q handled_list
;
1474 enum zebra_dplane_result res
;
1476 TAILQ_INIT(&handled_list
);
1479 ctx
= dplane_ctx_dequeue(ctx_list
);
1484 * A previous provider plugin may have asked to skip the
1487 if (dplane_ctx_is_skip_kernel(ctx
)) {
1488 res
= ZEBRA_DPLANE_REQUEST_SUCCESS
;
1492 switch (dplane_ctx_get_op(ctx
)) {
1494 case DPLANE_OP_ROUTE_INSTALL
:
1495 case DPLANE_OP_ROUTE_UPDATE
:
1496 case DPLANE_OP_ROUTE_DELETE
:
1497 res
= kernel_route_update(ctx
);
1500 case DPLANE_OP_NH_INSTALL
:
1501 case DPLANE_OP_NH_UPDATE
:
1502 case DPLANE_OP_NH_DELETE
:
1503 res
= kernel_nexthop_update(ctx
);
1506 case DPLANE_OP_LSP_INSTALL
:
1507 case DPLANE_OP_LSP_UPDATE
:
1508 case DPLANE_OP_LSP_DELETE
:
1509 res
= kernel_lsp_update(ctx
);
1512 case DPLANE_OP_PW_INSTALL
:
1513 case DPLANE_OP_PW_UNINSTALL
:
1514 res
= kernel_pw_update(ctx
);
1517 case DPLANE_OP_ADDR_INSTALL
:
1518 case DPLANE_OP_ADDR_UNINSTALL
:
1519 res
= kernel_address_update_ctx(ctx
);
1522 case DPLANE_OP_MAC_INSTALL
:
1523 case DPLANE_OP_MAC_DELETE
:
1524 res
= kernel_mac_update_ctx(ctx
);
1527 case DPLANE_OP_NEIGH_INSTALL
:
1528 case DPLANE_OP_NEIGH_UPDATE
:
1529 case DPLANE_OP_NEIGH_DELETE
:
1530 case DPLANE_OP_VTEP_ADD
:
1531 case DPLANE_OP_VTEP_DELETE
:
1532 case DPLANE_OP_NEIGH_DISCOVER
:
1533 res
= kernel_neigh_update_ctx(ctx
);
1536 case DPLANE_OP_RULE_ADD
:
1537 case DPLANE_OP_RULE_DELETE
:
1538 case DPLANE_OP_RULE_UPDATE
:
1539 res
= kernel_pbr_rule_update(ctx
);
1542 /* Ignore 'notifications' - no-op */
1543 case DPLANE_OP_SYS_ROUTE_ADD
:
1544 case DPLANE_OP_SYS_ROUTE_DELETE
:
1545 case DPLANE_OP_ROUTE_NOTIFY
:
1546 case DPLANE_OP_LSP_NOTIFY
:
1547 res
= ZEBRA_DPLANE_REQUEST_SUCCESS
;
1551 res
= ZEBRA_DPLANE_REQUEST_FAILURE
;
1556 dplane_ctx_set_status(ctx
, res
);
1558 dplane_ctx_enqueue_tail(&handled_list
, ctx
);
1561 TAILQ_INIT(ctx_list
);
1562 dplane_ctx_list_append(ctx_list
, &handled_list
);
1565 #endif /* !HAVE_NETLINK */