2 * Interface looking up by netlink.
3 * Copyright (C) 1998 Kunihiro Ishiguro
5 * This file is part of GNU Zebra.
7 * GNU Zebra is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
12 * GNU Zebra is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; see the file COPYING; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 /* The following definition is to workaround an issue in the Linux kernel
27 * header files with redefinition of 'struct in6_addr' in both
28 * netinet/in.h and linux/in6.h.
29 * Reference - https://sourceware.org/ml/libc-alpha/2013-01/msg00599.html
33 #include <netinet/if_ether.h>
34 #include <linux/if_bridge.h>
35 #include <linux/if_link.h>
36 #include <net/if_arp.h>
37 #include <linux/sockios.h>
38 #include <linux/ethtool.h>
44 #include "connected.h"
47 #include "zebra_memory.h"
55 #include "lib_errors.h"
58 #include "zebra/zserv.h"
59 #include "zebra/zebra_ns.h"
60 #include "zebra/zebra_vrf.h"
62 #include "zebra/redistribute.h"
63 #include "zebra/interface.h"
64 #include "zebra/debug.h"
65 #include "zebra/rtadv.h"
66 #include "zebra/zebra_ptm.h"
67 #include "zebra/zebra_mpls.h"
68 #include "zebra/kernel_netlink.h"
69 #include "zebra/if_netlink.h"
71 extern struct zebra_privs_t zserv_privs
;
73 /* Note: on netlink systems, there should be a 1-to-1 mapping between interface
74 names and ifindex values. */
75 static void set_ifindex(struct interface
*ifp
, ifindex_t ifi_index
,
78 struct interface
*oifp
;
80 if (((oifp
= if_lookup_by_index_per_ns(zns
, ifi_index
)) != NULL
)
82 if (ifi_index
== IFINDEX_INTERNAL
)
85 "Netlink is setting interface %s ifindex to reserved internal value %u",
86 ifp
->name
, ifi_index
);
88 if (IS_ZEBRA_DEBUG_KERNEL
)
90 "interface index %d was renamed from %s to %s",
91 ifi_index
, oifp
->name
, ifp
->name
);
95 "interface rename detected on up interface: index %d was renamed from %s to %s, results are uncertain!",
96 ifi_index
, oifp
->name
, ifp
->name
);
97 if_delete_update(oifp
);
100 if_set_index(ifp
, ifi_index
);
103 /* Utility function to parse hardware link-layer address and update ifp */
104 static void netlink_interface_update_hw_addr(struct rtattr
**tb
,
105 struct interface
*ifp
)
109 if (tb
[IFLA_ADDRESS
]) {
112 hw_addr_len
= RTA_PAYLOAD(tb
[IFLA_ADDRESS
]);
114 if (hw_addr_len
> INTERFACE_HWADDR_MAX
)
115 zlog_warn("Hardware address is too large: %d",
118 ifp
->hw_addr_len
= hw_addr_len
;
119 memcpy(ifp
->hw_addr
, RTA_DATA(tb
[IFLA_ADDRESS
]),
122 for (i
= 0; i
< hw_addr_len
; i
++)
123 if (ifp
->hw_addr
[i
] != 0)
126 if (i
== hw_addr_len
)
127 ifp
->hw_addr_len
= 0;
129 ifp
->hw_addr_len
= hw_addr_len
;
134 static enum zebra_link_type
netlink_to_zebra_link_type(unsigned int hwt
)
138 return ZEBRA_LLT_ETHER
;
140 return ZEBRA_LLT_EETHER
;
142 return ZEBRA_LLT_AX25
;
144 return ZEBRA_LLT_PRONET
;
146 return ZEBRA_LLT_IEEE802
;
148 return ZEBRA_LLT_ARCNET
;
149 case ARPHRD_APPLETLK
:
150 return ZEBRA_LLT_APPLETLK
;
152 return ZEBRA_LLT_DLCI
;
154 return ZEBRA_LLT_ATM
;
155 case ARPHRD_METRICOM
:
156 return ZEBRA_LLT_METRICOM
;
157 case ARPHRD_IEEE1394
:
158 return ZEBRA_LLT_IEEE1394
;
160 return ZEBRA_LLT_EUI64
;
161 case ARPHRD_INFINIBAND
:
162 return ZEBRA_LLT_INFINIBAND
;
164 return ZEBRA_LLT_SLIP
;
166 return ZEBRA_LLT_CSLIP
;
168 return ZEBRA_LLT_SLIP6
;
170 return ZEBRA_LLT_CSLIP6
;
172 return ZEBRA_LLT_RSRVD
;
174 return ZEBRA_LLT_ADAPT
;
176 return ZEBRA_LLT_ROSE
;
178 return ZEBRA_LLT_X25
;
180 return ZEBRA_LLT_PPP
;
182 return ZEBRA_LLT_CHDLC
;
184 return ZEBRA_LLT_LAPB
;
186 return ZEBRA_LLT_RAWHDLC
;
188 return ZEBRA_LLT_IPIP
;
190 return ZEBRA_LLT_IPIP6
;
192 return ZEBRA_LLT_FRAD
;
194 return ZEBRA_LLT_SKIP
;
195 case ARPHRD_LOOPBACK
:
196 return ZEBRA_LLT_LOOPBACK
;
197 case ARPHRD_LOCALTLK
:
198 return ZEBRA_LLT_LOCALTLK
;
200 return ZEBRA_LLT_FDDI
;
202 return ZEBRA_LLT_SIT
;
204 return ZEBRA_LLT_IPDDP
;
206 return ZEBRA_LLT_IPGRE
;
208 return ZEBRA_LLT_PIMREG
;
210 return ZEBRA_LLT_HIPPI
;
212 return ZEBRA_LLT_ECONET
;
214 return ZEBRA_LLT_IRDA
;
216 return ZEBRA_LLT_FCPP
;
218 return ZEBRA_LLT_FCAL
;
220 return ZEBRA_LLT_FCPL
;
221 case ARPHRD_FCFABRIC
:
222 return ZEBRA_LLT_FCFABRIC
;
223 case ARPHRD_IEEE802_TR
:
224 return ZEBRA_LLT_IEEE802_TR
;
225 case ARPHRD_IEEE80211
:
226 return ZEBRA_LLT_IEEE80211
;
227 #ifdef ARPHRD_IEEE802154
228 case ARPHRD_IEEE802154
:
229 return ZEBRA_LLT_IEEE802154
;
233 return ZEBRA_LLT_IP6GRE
;
235 #ifdef ARPHRD_IEEE802154_PHY
236 case ARPHRD_IEEE802154_PHY
:
237 return ZEBRA_LLT_IEEE802154_PHY
;
241 return ZEBRA_LLT_UNKNOWN
;
245 static void netlink_determine_zebra_iftype(char *kind
, zebra_iftype_t
*zif_type
)
247 *zif_type
= ZEBRA_IF_OTHER
;
252 if (strcmp(kind
, "vrf") == 0)
253 *zif_type
= ZEBRA_IF_VRF
;
254 else if (strcmp(kind
, "bridge") == 0)
255 *zif_type
= ZEBRA_IF_BRIDGE
;
256 else if (strcmp(kind
, "vlan") == 0)
257 *zif_type
= ZEBRA_IF_VLAN
;
258 else if (strcmp(kind
, "vxlan") == 0)
259 *zif_type
= ZEBRA_IF_VXLAN
;
260 else if (strcmp(kind
, "macvlan") == 0)
261 *zif_type
= ZEBRA_IF_MACVLAN
;
262 else if (strcmp(kind
, "veth") == 0)
263 *zif_type
= ZEBRA_IF_VETH
;
266 #define parse_rtattr_nested(tb, max, rta) \
267 netlink_parse_rtattr((tb), (max), RTA_DATA(rta), RTA_PAYLOAD(rta))
269 static void netlink_vrf_change(struct nlmsghdr
*h
, struct rtattr
*tb
,
272 struct ifinfomsg
*ifi
;
273 struct rtattr
*linkinfo
[IFLA_INFO_MAX
+ 1];
274 struct rtattr
*attr
[IFLA_VRF_MAX
+ 1];
276 struct zebra_vrf
*zvrf
;
277 uint32_t nl_table_id
;
281 memset(linkinfo
, 0, sizeof linkinfo
);
282 parse_rtattr_nested(linkinfo
, IFLA_INFO_MAX
, tb
);
284 if (!linkinfo
[IFLA_INFO_DATA
]) {
285 if (IS_ZEBRA_DEBUG_KERNEL
)
287 "%s: IFLA_INFO_DATA missing from VRF message: %s",
292 memset(attr
, 0, sizeof attr
);
293 parse_rtattr_nested(attr
, IFLA_VRF_MAX
, linkinfo
[IFLA_INFO_DATA
]);
294 if (!attr
[IFLA_VRF_TABLE
]) {
295 if (IS_ZEBRA_DEBUG_KERNEL
)
297 "%s: IFLA_VRF_TABLE missing from VRF message: %s",
302 nl_table_id
= *(uint32_t *)RTA_DATA(attr
[IFLA_VRF_TABLE
]);
304 if (h
->nlmsg_type
== RTM_NEWLINK
) {
305 if (IS_ZEBRA_DEBUG_KERNEL
)
306 zlog_debug("RTM_NEWLINK for VRF %s(%u) table %u", name
,
307 ifi
->ifi_index
, nl_table_id
);
310 * vrf_get is implied creation if it does not exist
312 vrf
= vrf_get((vrf_id_t
)ifi
->ifi_index
,
313 name
); // It would create vrf
315 flog_err(LIB_ERR_INTERFACE
, "VRF %s id %u not created",
316 name
, ifi
->ifi_index
);
321 * This is the only place that we get the actual kernel table_id
322 * being used. We need it to set the table_id of the routes
323 * we are passing to the kernel.... And to throw some totally
324 * awesome parties. that too.
326 * At this point we *must* have a zvrf because the vrf_create
327 * callback creates one. We *must* set the table id
328 * before the vrf_enable because of( at the very least )
329 * static routes being delayed for installation until
330 * during the vrf_enable callbacks.
332 zvrf
= (struct zebra_vrf
*)vrf
->info
;
333 zvrf
->table_id
= nl_table_id
;
335 /* Enable the created VRF. */
336 if (!vrf_enable(vrf
)) {
337 flog_err(LIB_ERR_INTERFACE
,
338 "Failed to enable VRF %s id %u", name
,
343 } else // h->nlmsg_type == RTM_DELLINK
345 if (IS_ZEBRA_DEBUG_KERNEL
)
346 zlog_debug("RTM_DELLINK for VRF %s(%u)", name
,
349 vrf
= vrf_lookup_by_id((vrf_id_t
)ifi
->ifi_index
);
352 zlog_warn("%s: vrf not found", __func__
);
360 static int get_iflink_speed(struct interface
*interface
)
363 struct ethtool_cmd ecmd
;
366 const char *ifname
= interface
->name
;
368 /* initialize struct */
369 memset(&ifdata
, 0, sizeof(ifdata
));
371 /* set interface name */
372 strlcpy(ifdata
.ifr_name
, ifname
, sizeof(ifdata
.ifr_name
));
374 /* initialize ethtool interface */
375 memset(&ecmd
, 0, sizeof(ecmd
));
376 ecmd
.cmd
= ETHTOOL_GSET
; /* ETHTOOL_GLINK */
377 ifdata
.ifr_data
= (caddr_t
)&ecmd
;
379 /* use ioctl to get IP address of an interface */
380 frr_elevate_privs(&zserv_privs
) {
381 sd
= vrf_socket(PF_INET
, SOCK_DGRAM
, IPPROTO_IP
,
385 if (IS_ZEBRA_DEBUG_KERNEL
)
386 zlog_debug("Failure to read interface %s speed: %d %s",
387 ifname
, errno
, safe_strerror(errno
));
390 /* Get the current link state for the interface */
391 rc
= vrf_ioctl(interface
->vrf_id
, sd
, SIOCETHTOOL
,
395 if (IS_ZEBRA_DEBUG_KERNEL
)
397 "IOCTL failure to read interface %s speed: %d %s",
398 ifname
, errno
, safe_strerror(errno
));
405 return (ecmd
.speed_hi
<< 16) | ecmd
.speed
;
408 uint32_t kernel_get_speed(struct interface
*ifp
)
410 return get_iflink_speed(ifp
);
413 static int netlink_extract_bridge_info(struct rtattr
*link_data
,
414 struct zebra_l2info_bridge
*bridge_info
)
416 struct rtattr
*attr
[IFLA_BR_MAX
+ 1];
418 memset(bridge_info
, 0, sizeof(*bridge_info
));
419 memset(attr
, 0, sizeof attr
);
420 parse_rtattr_nested(attr
, IFLA_BR_MAX
, link_data
);
421 if (attr
[IFLA_BR_VLAN_FILTERING
])
422 bridge_info
->vlan_aware
=
423 *(uint8_t *)RTA_DATA(attr
[IFLA_BR_VLAN_FILTERING
]);
427 static int netlink_extract_vlan_info(struct rtattr
*link_data
,
428 struct zebra_l2info_vlan
*vlan_info
)
430 struct rtattr
*attr
[IFLA_VLAN_MAX
+ 1];
433 memset(vlan_info
, 0, sizeof(*vlan_info
));
434 memset(attr
, 0, sizeof attr
);
435 parse_rtattr_nested(attr
, IFLA_VLAN_MAX
, link_data
);
436 if (!attr
[IFLA_VLAN_ID
]) {
437 if (IS_ZEBRA_DEBUG_KERNEL
)
438 zlog_debug("IFLA_VLAN_ID missing from VLAN IF message");
442 vid_in_msg
= *(vlanid_t
*)RTA_DATA(attr
[IFLA_VLAN_ID
]);
443 vlan_info
->vid
= vid_in_msg
;
447 static int netlink_extract_vxlan_info(struct rtattr
*link_data
,
448 struct zebra_l2info_vxlan
*vxl_info
)
450 struct rtattr
*attr
[IFLA_VXLAN_MAX
+ 1];
452 struct in_addr vtep_ip_in_msg
;
454 memset(vxl_info
, 0, sizeof(*vxl_info
));
455 memset(attr
, 0, sizeof attr
);
456 parse_rtattr_nested(attr
, IFLA_VXLAN_MAX
, link_data
);
457 if (!attr
[IFLA_VXLAN_ID
]) {
458 if (IS_ZEBRA_DEBUG_KERNEL
)
460 "IFLA_VXLAN_ID missing from VXLAN IF message");
464 vni_in_msg
= *(vni_t
*)RTA_DATA(attr
[IFLA_VXLAN_ID
]);
465 vxl_info
->vni
= vni_in_msg
;
466 if (!attr
[IFLA_VXLAN_LOCAL
]) {
467 if (IS_ZEBRA_DEBUG_KERNEL
)
469 "IFLA_VXLAN_LOCAL missing from VXLAN IF message");
472 *(struct in_addr
*)RTA_DATA(attr
[IFLA_VXLAN_LOCAL
]);
473 vxl_info
->vtep_ip
= vtep_ip_in_msg
;
480 * Extract and save L2 params (of interest) for an interface. When a
481 * bridge interface is added or updated, take further actions to map
482 * its members. Likewise, for VxLAN interface.
484 static void netlink_interface_update_l2info(struct interface
*ifp
,
485 struct rtattr
*link_data
, int add
)
490 if (IS_ZEBRA_IF_BRIDGE(ifp
)) {
491 struct zebra_l2info_bridge bridge_info
;
493 netlink_extract_bridge_info(link_data
, &bridge_info
);
494 zebra_l2_bridge_add_update(ifp
, &bridge_info
, add
);
495 } else if (IS_ZEBRA_IF_VLAN(ifp
)) {
496 struct zebra_l2info_vlan vlan_info
;
498 netlink_extract_vlan_info(link_data
, &vlan_info
);
499 zebra_l2_vlanif_update(ifp
, &vlan_info
);
500 } else if (IS_ZEBRA_IF_VXLAN(ifp
)) {
501 struct zebra_l2info_vxlan vxlan_info
;
503 netlink_extract_vxlan_info(link_data
, &vxlan_info
);
504 zebra_l2_vxlanif_add_update(ifp
, &vxlan_info
, add
);
508 static int netlink_bridge_interface(struct nlmsghdr
*h
, int len
, ns_id_t ns_id
,
512 struct ifinfomsg
*ifi
;
513 struct rtattr
*tb
[IFLA_MAX
+ 1];
514 struct interface
*ifp
;
515 struct rtattr
*aftb
[IFLA_BRIDGE_MAX
+ 1];
520 vlanid_t access_vlan
;
522 /* Fetch name and ifindex */
524 memset(tb
, 0, sizeof tb
);
525 netlink_parse_rtattr(tb
, IFLA_MAX
, IFLA_RTA(ifi
), len
);
527 if (tb
[IFLA_IFNAME
] == NULL
)
529 name
= (char *)RTA_DATA(tb
[IFLA_IFNAME
]);
531 /* The interface should already be known, if not discard. */
532 ifp
= if_lookup_by_index_per_ns(zebra_ns_lookup(ns_id
), ifi
->ifi_index
);
534 zlog_warn("Cannot find bridge IF %s(%u)", name
, ifi
->ifi_index
);
537 if (!IS_ZEBRA_IF_VXLAN(ifp
))
540 /* We are only interested in the access VLAN i.e., AF_SPEC */
541 if (!tb
[IFLA_AF_SPEC
])
544 /* There is a 1-to-1 mapping of VLAN to VxLAN - hence
545 * only 1 access VLAN is accepted.
547 memset(aftb
, 0, sizeof aftb
);
548 parse_rtattr_nested(aftb
, IFLA_BRIDGE_MAX
, tb
[IFLA_AF_SPEC
]);
549 if (!aftb
[IFLA_BRIDGE_VLAN_INFO
])
552 vinfo
= RTA_DATA(aftb
[IFLA_BRIDGE_VLAN_INFO
]);
553 if (!(vinfo
->flags
& BRIDGE_VLAN_INFO_PVID
))
556 access_vlan
= (vlanid_t
)vinfo
->vid
;
557 if (IS_ZEBRA_DEBUG_KERNEL
)
558 zlog_debug("Access VLAN %u for VxLAN IF %s(%u)", access_vlan
,
559 name
, ifi
->ifi_index
);
560 zebra_l2_vxlanif_update_access_vlan(ifp
, access_vlan
);
565 * Called from interface_lookup_netlink(). This function is only used
568 static int netlink_interface(struct nlmsghdr
*h
, ns_id_t ns_id
, int startup
)
571 struct ifinfomsg
*ifi
;
572 struct rtattr
*tb
[IFLA_MAX
+ 1];
573 struct rtattr
*linkinfo
[IFLA_MAX
+ 1];
574 struct interface
*ifp
;
578 char *slave_kind
= NULL
;
579 struct zebra_ns
*zns
;
580 vrf_id_t vrf_id
= VRF_DEFAULT
;
581 zebra_iftype_t zif_type
= ZEBRA_IF_OTHER
;
582 zebra_slave_iftype_t zif_slave_type
= ZEBRA_IF_SLAVE_NONE
;
583 ifindex_t bridge_ifindex
= IFINDEX_INTERNAL
;
584 ifindex_t link_ifindex
= IFINDEX_INTERNAL
;
586 zns
= zebra_ns_lookup(ns_id
);
589 if (h
->nlmsg_type
!= RTM_NEWLINK
)
592 len
= h
->nlmsg_len
- NLMSG_LENGTH(sizeof(struct ifinfomsg
));
594 zlog_err("%s: Message received from netlink is of a broken size: %d %zu",
597 (size_t)NLMSG_LENGTH(sizeof(struct ifinfomsg
)));
601 /* We are interested in some AF_BRIDGE notifications. */
602 if (ifi
->ifi_family
== AF_BRIDGE
)
603 return netlink_bridge_interface(h
, len
, ns_id
, startup
);
605 /* Looking up interface name. */
606 memset(tb
, 0, sizeof tb
);
607 memset(linkinfo
, 0, sizeof linkinfo
);
608 netlink_parse_rtattr(tb
, IFLA_MAX
, IFLA_RTA(ifi
), len
);
610 /* check for wireless messages to ignore */
611 if ((tb
[IFLA_WIRELESS
] != NULL
) && (ifi
->ifi_change
== 0)) {
612 if (IS_ZEBRA_DEBUG_KERNEL
)
613 zlog_debug("%s: ignoring IFLA_WIRELESS message",
618 if (tb
[IFLA_IFNAME
] == NULL
)
620 name
= (char *)RTA_DATA(tb
[IFLA_IFNAME
]);
622 if (tb
[IFLA_IFALIAS
])
623 desc
= (char *)RTA_DATA(tb
[IFLA_IFALIAS
]);
625 if (tb
[IFLA_LINKINFO
]) {
626 parse_rtattr_nested(linkinfo
, IFLA_INFO_MAX
, tb
[IFLA_LINKINFO
]);
628 if (linkinfo
[IFLA_INFO_KIND
])
629 kind
= RTA_DATA(linkinfo
[IFLA_INFO_KIND
]);
631 if (linkinfo
[IFLA_INFO_SLAVE_KIND
])
632 slave_kind
= RTA_DATA(linkinfo
[IFLA_INFO_SLAVE_KIND
]);
634 netlink_determine_zebra_iftype(kind
, &zif_type
);
637 /* If VRF, create the VRF structure itself. */
638 if (zif_type
== ZEBRA_IF_VRF
&& !vrf_is_backend_netns()) {
639 netlink_vrf_change(h
, tb
[IFLA_LINKINFO
], name
);
640 vrf_id
= (vrf_id_t
)ifi
->ifi_index
;
643 if (tb
[IFLA_MASTER
]) {
644 if (slave_kind
&& (strcmp(slave_kind
, "vrf") == 0)
645 && !vrf_is_backend_netns()) {
646 zif_slave_type
= ZEBRA_IF_SLAVE_VRF
;
647 vrf_id
= *(uint32_t *)RTA_DATA(tb
[IFLA_MASTER
]);
648 } else if (slave_kind
&& (strcmp(slave_kind
, "bridge") == 0)) {
649 zif_slave_type
= ZEBRA_IF_SLAVE_BRIDGE
;
651 *(ifindex_t
*)RTA_DATA(tb
[IFLA_MASTER
]);
653 zif_slave_type
= ZEBRA_IF_SLAVE_OTHER
;
655 if (vrf_is_backend_netns())
656 vrf_id
= (vrf_id_t
)ns_id
;
658 /* If linking to another interface, note it. */
660 link_ifindex
= *(ifindex_t
*)RTA_DATA(tb
[IFLA_LINK
]);
663 ifp
= if_get_by_name(name
, vrf_id
, 0);
664 set_ifindex(ifp
, ifi
->ifi_index
, zns
);
665 ifp
->flags
= ifi
->ifi_flags
& 0x0000fffff;
666 ifp
->mtu6
= ifp
->mtu
= *(uint32_t *)RTA_DATA(tb
[IFLA_MTU
]);
668 ifp
->speed
= get_iflink_speed(ifp
);
669 ifp
->ptm_status
= ZEBRA_PTM_STATUS_UNKNOWN
;
672 ifp
->desc
= XSTRDUP(MTYPE_TMP
, desc
);
674 /* Set zebra interface type */
675 zebra_if_set_ziftype(ifp
, zif_type
, zif_slave_type
);
676 if (IS_ZEBRA_IF_VRF(ifp
))
677 SET_FLAG(ifp
->status
, ZEBRA_INTERFACE_VRF_LOOPBACK
);
680 zebra_if_update_link(ifp
, link_ifindex
, ns_id
);
682 /* Hardware type and address. */
683 ifp
->ll_type
= netlink_to_zebra_link_type(ifi
->ifi_type
);
684 netlink_interface_update_hw_addr(tb
, ifp
);
688 /* Extract and save L2 interface information, take additional actions.
690 netlink_interface_update_l2info(ifp
, linkinfo
[IFLA_INFO_DATA
], 1);
691 if (IS_ZEBRA_IF_BRIDGE_SLAVE(ifp
))
692 zebra_l2if_update_bridge_slave(ifp
, bridge_ifindex
);
697 /* Request for specific interface or address information from the kernel */
698 static int netlink_request_intf_addr(struct zebra_ns
*zns
, int family
, int type
,
699 uint32_t filter_mask
)
703 struct ifinfomsg ifm
;
707 /* Form the request, specifying filter (rtattr) if needed. */
708 memset(&req
, 0, sizeof(req
));
709 req
.n
.nlmsg_type
= type
;
710 req
.n
.nlmsg_len
= NLMSG_LENGTH(sizeof(struct ifinfomsg
));
711 req
.ifm
.ifi_family
= family
;
713 /* Include filter, if specified. */
715 addattr32(&req
.n
, sizeof(req
), IFLA_EXT_MASK
, filter_mask
);
717 return netlink_request(&zns
->netlink_cmd
, &req
.n
);
720 /* Interface lookup by netlink socket. */
721 int interface_lookup_netlink(struct zebra_ns
*zns
)
725 /* Get interface information. */
726 ret
= netlink_request_intf_addr(zns
, AF_PACKET
, RTM_GETLINK
, 0);
729 ret
= netlink_parse_info(netlink_interface
, &zns
->netlink_cmd
, zns
, 0,
734 /* Get interface information - for bridge interfaces. */
735 ret
= netlink_request_intf_addr(zns
, AF_BRIDGE
, RTM_GETLINK
,
736 RTEXT_FILTER_BRVLAN
);
739 ret
= netlink_parse_info(netlink_interface
, &zns
->netlink_cmd
, zns
, 0,
744 /* Get interface information - for bridge interfaces. */
745 ret
= netlink_request_intf_addr(zns
, AF_BRIDGE
, RTM_GETLINK
,
746 RTEXT_FILTER_BRVLAN
);
749 ret
= netlink_parse_info(netlink_interface
, &zns
->netlink_cmd
, zns
, 0,
754 /* Get IPv4 address of the interfaces. */
755 ret
= netlink_request_intf_addr(zns
, AF_INET
, RTM_GETADDR
, 0);
758 ret
= netlink_parse_info(netlink_interface_addr
, &zns
->netlink_cmd
, zns
,
763 /* Get IPv6 address of the interfaces. */
764 ret
= netlink_request_intf_addr(zns
, AF_INET6
, RTM_GETADDR
, 0);
767 ret
= netlink_parse_info(netlink_interface_addr
, &zns
->netlink_cmd
, zns
,
775 int kernel_interface_set_master(struct interface
*master
,
776 struct interface
*slave
)
778 struct zebra_ns
*zns
= zebra_ns_lookup(NS_DEFAULT
);
782 struct ifinfomsg ifa
;
783 char buf
[NL_PKT_BUF_SIZE
];
786 memset(&req
, 0, sizeof req
);
788 req
.n
.nlmsg_len
= NLMSG_LENGTH(sizeof(struct ifinfomsg
));
789 req
.n
.nlmsg_flags
= NLM_F_REQUEST
;
790 req
.n
.nlmsg_type
= RTM_SETLINK
;
791 req
.n
.nlmsg_pid
= zns
->netlink_cmd
.snl
.nl_pid
;
793 req
.ifa
.ifi_index
= slave
->ifindex
;
795 addattr_l(&req
.n
, sizeof req
, IFLA_MASTER
, &master
->ifindex
, 4);
796 addattr_l(&req
.n
, sizeof req
, IFLA_LINK
, &slave
->ifindex
, 4);
798 return netlink_talk(netlink_talk_filter
, &req
.n
, &zns
->netlink_cmd
, zns
,
802 /* Interface address modification. */
803 static int netlink_address(int cmd
, int family
, struct interface
*ifp
,
804 struct connected
*ifc
)
811 struct ifaddrmsg ifa
;
812 char buf
[NL_PKT_BUF_SIZE
];
815 struct zebra_ns
*zns
;
817 if (vrf_is_backend_netns())
818 zns
= zebra_ns_lookup((ns_id_t
)ifp
->vrf_id
);
820 zns
= zebra_ns_lookup(NS_DEFAULT
);
822 memset(&req
, 0, sizeof req
- NL_PKT_BUF_SIZE
);
824 bytelen
= (family
== AF_INET
? 4 : 16);
826 req
.n
.nlmsg_len
= NLMSG_LENGTH(sizeof(struct ifaddrmsg
));
827 req
.n
.nlmsg_flags
= NLM_F_REQUEST
;
828 req
.n
.nlmsg_type
= cmd
;
829 req
.n
.nlmsg_pid
= zns
->netlink_cmd
.snl
.nl_pid
;
831 req
.ifa
.ifa_family
= family
;
833 req
.ifa
.ifa_index
= ifp
->ifindex
;
835 addattr_l(&req
.n
, sizeof req
, IFA_LOCAL
, &p
->u
.prefix
, bytelen
);
837 if (family
== AF_INET
) {
838 if (CONNECTED_PEER(ifc
)) {
839 p
= ifc
->destination
;
840 addattr_l(&req
.n
, sizeof req
, IFA_ADDRESS
, &p
->u
.prefix
,
842 } else if (cmd
== RTM_NEWADDR
&& ifc
->destination
) {
843 p
= ifc
->destination
;
844 addattr_l(&req
.n
, sizeof req
, IFA_BROADCAST
,
845 &p
->u
.prefix
, bytelen
);
849 /* p is now either ifc->address or ifc->destination */
850 req
.ifa
.ifa_prefixlen
= p
->prefixlen
;
852 if (CHECK_FLAG(ifc
->flags
, ZEBRA_IFA_SECONDARY
))
853 SET_FLAG(req
.ifa
.ifa_flags
, IFA_F_SECONDARY
);
856 addattr_l(&req
.n
, sizeof req
, IFA_LABEL
, ifc
->label
,
857 strlen(ifc
->label
) + 1);
859 return netlink_talk(netlink_talk_filter
, &req
.n
, &zns
->netlink_cmd
, zns
,
863 int kernel_address_add_ipv4(struct interface
*ifp
, struct connected
*ifc
)
865 return netlink_address(RTM_NEWADDR
, AF_INET
, ifp
, ifc
);
868 int kernel_address_delete_ipv4(struct interface
*ifp
, struct connected
*ifc
)
870 return netlink_address(RTM_DELADDR
, AF_INET
, ifp
, ifc
);
873 int kernel_address_add_ipv6(struct interface
*ifp
, struct connected
*ifc
)
875 return netlink_address(RTM_NEWADDR
, AF_INET6
, ifp
, ifc
);
878 int kernel_address_delete_ipv6(struct interface
*ifp
, struct connected
*ifc
)
880 return netlink_address(RTM_DELADDR
, AF_INET6
, ifp
, ifc
);
883 int netlink_interface_addr(struct nlmsghdr
*h
, ns_id_t ns_id
, int startup
)
886 struct ifaddrmsg
*ifa
;
887 struct rtattr
*tb
[IFA_MAX
+ 1];
888 struct interface
*ifp
;
893 struct zebra_ns
*zns
;
895 zns
= zebra_ns_lookup(ns_id
);
898 if (ifa
->ifa_family
!= AF_INET
&& ifa
->ifa_family
!= AF_INET6
) {
900 "Invalid address family: %u received from kernel interface addr change: %u",
901 ifa
->ifa_family
, h
->nlmsg_type
);
905 if (h
->nlmsg_type
!= RTM_NEWADDR
&& h
->nlmsg_type
!= RTM_DELADDR
)
908 len
= h
->nlmsg_len
- NLMSG_LENGTH(sizeof(struct ifaddrmsg
));
910 zlog_err("%s: Message received from netlink is of a broken size: %d %zu",
913 (size_t)NLMSG_LENGTH(sizeof(struct ifaddrmsg
)));
917 memset(tb
, 0, sizeof tb
);
918 netlink_parse_rtattr(tb
, IFA_MAX
, IFA_RTA(ifa
), len
);
920 ifp
= if_lookup_by_index_per_ns(zns
, ifa
->ifa_index
);
924 "netlink_interface_addr can't find interface by index %d",
929 if (IS_ZEBRA_DEBUG_KERNEL
) /* remove this line to see initial ifcfg */
932 zlog_debug("netlink_interface_addr %s %s flags 0x%x:",
933 nl_msg_type_to_str(h
->nlmsg_type
), ifp
->name
,
936 zlog_debug(" IFA_LOCAL %s/%d",
937 inet_ntop(ifa
->ifa_family
,
938 RTA_DATA(tb
[IFA_LOCAL
]), buf
,
942 zlog_debug(" IFA_ADDRESS %s/%d",
943 inet_ntop(ifa
->ifa_family
,
944 RTA_DATA(tb
[IFA_ADDRESS
]), buf
,
947 if (tb
[IFA_BROADCAST
])
948 zlog_debug(" IFA_BROADCAST %s/%d",
949 inet_ntop(ifa
->ifa_family
,
950 RTA_DATA(tb
[IFA_BROADCAST
]), buf
,
953 if (tb
[IFA_LABEL
] && strcmp(ifp
->name
, RTA_DATA(tb
[IFA_LABEL
])))
954 zlog_debug(" IFA_LABEL %s",
955 (char *)RTA_DATA(tb
[IFA_LABEL
]));
957 if (tb
[IFA_CACHEINFO
]) {
958 struct ifa_cacheinfo
*ci
= RTA_DATA(tb
[IFA_CACHEINFO
]);
959 zlog_debug(" IFA_CACHEINFO pref %d, valid %d",
960 ci
->ifa_prefered
, ci
->ifa_valid
);
964 /* logic copied from iproute2/ip/ipaddress.c:print_addrinfo() */
965 if (tb
[IFA_LOCAL
] == NULL
)
966 tb
[IFA_LOCAL
] = tb
[IFA_ADDRESS
];
967 if (tb
[IFA_ADDRESS
] == NULL
)
968 tb
[IFA_ADDRESS
] = tb
[IFA_LOCAL
];
970 /* local interface address */
971 addr
= (tb
[IFA_LOCAL
] ? RTA_DATA(tb
[IFA_LOCAL
]) : NULL
);
973 /* is there a peer address? */
975 && memcmp(RTA_DATA(tb
[IFA_ADDRESS
]), RTA_DATA(tb
[IFA_LOCAL
]),
976 RTA_PAYLOAD(tb
[IFA_ADDRESS
]))) {
977 broad
= RTA_DATA(tb
[IFA_ADDRESS
]);
978 SET_FLAG(flags
, ZEBRA_IFA_PEER
);
980 /* seeking a broadcast address */
981 broad
= (tb
[IFA_BROADCAST
] ? RTA_DATA(tb
[IFA_BROADCAST
])
984 /* addr is primary key, SOL if we don't have one */
986 zlog_debug("%s: NULL address", __func__
);
991 if (ifa
->ifa_flags
& IFA_F_SECONDARY
)
992 SET_FLAG(flags
, ZEBRA_IFA_SECONDARY
);
996 label
= (char *)RTA_DATA(tb
[IFA_LABEL
]);
998 if (label
&& strcmp(ifp
->name
, label
) == 0)
1001 /* Register interface address to the interface. */
1002 if (ifa
->ifa_family
== AF_INET
) {
1003 if (ifa
->ifa_prefixlen
> IPV4_MAX_BITLEN
) {
1005 "Invalid prefix length: %u received from kernel interface addr change: %u",
1006 ifa
->ifa_prefixlen
, h
->nlmsg_type
);
1009 if (h
->nlmsg_type
== RTM_NEWADDR
)
1010 connected_add_ipv4(ifp
, flags
, (struct in_addr
*)addr
,
1012 (struct in_addr
*)broad
, label
);
1014 connected_delete_ipv4(
1015 ifp
, flags
, (struct in_addr
*)addr
,
1016 ifa
->ifa_prefixlen
, (struct in_addr
*)broad
);
1018 if (ifa
->ifa_family
== AF_INET6
) {
1019 if (ifa
->ifa_prefixlen
> IPV6_MAX_BITLEN
) {
1021 "Invalid prefix length: %u received from kernel interface addr change: %u",
1022 ifa
->ifa_prefixlen
, h
->nlmsg_type
);
1025 if (h
->nlmsg_type
== RTM_NEWADDR
) {
1026 /* Only consider valid addresses; we'll not get a
1028 * the kernel till IPv6 DAD has completed, but at init
1030 * does query for and will receive all addresses.
1032 if (!(ifa
->ifa_flags
1033 & (IFA_F_DADFAILED
| IFA_F_TENTATIVE
)))
1034 connected_add_ipv6(ifp
, flags
,
1035 (struct in6_addr
*)addr
,
1036 (struct in6_addr
*)broad
,
1037 ifa
->ifa_prefixlen
, label
);
1039 connected_delete_ipv6(ifp
, (struct in6_addr
*)addr
,
1040 (struct in6_addr
*)broad
,
1041 ifa
->ifa_prefixlen
);
1047 /* helper function called by if_netlink_change
1048 * to delete interfaces in case the interface moved
1051 static void if_netlink_check_ifp_instance_consistency(uint16_t cmd
,
1052 struct interface
*ifp
,
1055 struct interface
*other_ifp
;
1058 * look if interface name is also found on other netns
1059 * - only if vrf backend is netns
1060 * - do not concern lo interface
1061 * - then remove previous one
1062 * - for new link case, check found interface is not active
1064 if (!vrf_is_backend_netns() ||
1065 !strcmp(ifp
->name
, "lo"))
1067 other_ifp
= if_lookup_by_name_not_ns(ns_id
, ifp
->name
);
1070 /* because previous interface may be inactive,
1071 * interface is moved back to default vrf
1072 * then one may find the same pointer; ignore
1074 if (other_ifp
== ifp
)
1076 if ((cmd
== RTM_NEWLINK
)
1077 && (CHECK_FLAG(other_ifp
->status
, ZEBRA_INTERFACE_ACTIVE
)))
1079 if (IS_ZEBRA_DEBUG_KERNEL
&& cmd
== RTM_NEWLINK
) {
1080 zlog_debug("RTM_NEWLINK %s(%u, VRF %u) replaces %s(%u, VRF %u)\n",
1087 } else if (IS_ZEBRA_DEBUG_KERNEL
&& cmd
== RTM_DELLINK
) {
1088 zlog_debug("RTM_DELLINK %s(%u, VRF %u) is replaced by %s(%u, VRF %u)\n",
1096 /* the found interface replaces the current one
1099 if (cmd
== RTM_DELLINK
)
1102 if_delete(other_ifp
);
1103 /* the found interface is replaced by the current one
1108 int netlink_link_change(struct nlmsghdr
*h
, ns_id_t ns_id
, int startup
)
1111 struct ifinfomsg
*ifi
;
1112 struct rtattr
*tb
[IFLA_MAX
+ 1];
1113 struct rtattr
*linkinfo
[IFLA_MAX
+ 1];
1114 struct interface
*ifp
;
1118 char *slave_kind
= NULL
;
1119 struct zebra_ns
*zns
;
1120 vrf_id_t vrf_id
= VRF_DEFAULT
;
1121 zebra_iftype_t zif_type
= ZEBRA_IF_OTHER
;
1122 zebra_slave_iftype_t zif_slave_type
= ZEBRA_IF_SLAVE_NONE
;
1123 ifindex_t bridge_ifindex
= IFINDEX_INTERNAL
;
1124 ifindex_t link_ifindex
= IFINDEX_INTERNAL
;
1127 zns
= zebra_ns_lookup(ns_id
);
1128 ifi
= NLMSG_DATA(h
);
1130 /* assume if not default zns, then new VRF */
1131 if (!(h
->nlmsg_type
== RTM_NEWLINK
|| h
->nlmsg_type
== RTM_DELLINK
)) {
1132 /* If this is not link add/delete message so print warning. */
1133 zlog_warn("netlink_link_change: wrong kernel message %d",
1138 if (!(ifi
->ifi_family
== AF_UNSPEC
|| ifi
->ifi_family
== AF_BRIDGE
1139 || ifi
->ifi_family
== AF_INET6
)) {
1141 "Invalid address family: %u received from kernel link change: %u",
1142 ifi
->ifi_family
, h
->nlmsg_type
);
1146 len
= h
->nlmsg_len
- NLMSG_LENGTH(sizeof(struct ifinfomsg
));
1148 zlog_err("%s: Message received from netlink is of a broken size %d %zu",
1149 __PRETTY_FUNCTION__
, h
->nlmsg_len
,
1150 (size_t)NLMSG_LENGTH(sizeof(struct ifinfomsg
)));
1154 /* We are interested in some AF_BRIDGE notifications. */
1155 if (ifi
->ifi_family
== AF_BRIDGE
)
1156 return netlink_bridge_interface(h
, len
, ns_id
, startup
);
1158 /* Looking up interface name. */
1159 memset(tb
, 0, sizeof tb
);
1160 memset(linkinfo
, 0, sizeof linkinfo
);
1161 netlink_parse_rtattr(tb
, IFLA_MAX
, IFLA_RTA(ifi
), len
);
1163 /* check for wireless messages to ignore */
1164 if ((tb
[IFLA_WIRELESS
] != NULL
) && (ifi
->ifi_change
== 0)) {
1165 if (IS_ZEBRA_DEBUG_KERNEL
)
1166 zlog_debug("%s: ignoring IFLA_WIRELESS message",
1171 if (tb
[IFLA_IFNAME
] == NULL
)
1173 name
= (char *)RTA_DATA(tb
[IFLA_IFNAME
]);
1175 if (tb
[IFLA_LINKINFO
]) {
1176 parse_rtattr_nested(linkinfo
, IFLA_INFO_MAX
, tb
[IFLA_LINKINFO
]);
1178 if (linkinfo
[IFLA_INFO_KIND
])
1179 kind
= RTA_DATA(linkinfo
[IFLA_INFO_KIND
]);
1181 if (linkinfo
[IFLA_INFO_SLAVE_KIND
])
1182 slave_kind
= RTA_DATA(linkinfo
[IFLA_INFO_SLAVE_KIND
]);
1184 netlink_determine_zebra_iftype(kind
, &zif_type
);
1187 /* If linking to another interface, note it. */
1189 link_ifindex
= *(ifindex_t
*)RTA_DATA(tb
[IFLA_LINK
]);
1191 if (tb
[IFLA_IFALIAS
]) {
1192 desc
= (char *)RTA_DATA(tb
[IFLA_IFALIAS
]);
1195 /* If VRF, create or update the VRF structure itself. */
1196 if (zif_type
== ZEBRA_IF_VRF
&& !vrf_is_backend_netns()) {
1197 netlink_vrf_change(h
, tb
[IFLA_LINKINFO
], name
);
1198 vrf_id
= (vrf_id_t
)ifi
->ifi_index
;
1201 /* See if interface is present. */
1202 ifp
= if_lookup_by_name_per_ns(zns
, name
);
1206 XFREE(MTYPE_TMP
, ifp
->desc
);
1208 ifp
->desc
= XSTRDUP(MTYPE_TMP
, desc
);
1211 if (h
->nlmsg_type
== RTM_NEWLINK
) {
1212 if (tb
[IFLA_MASTER
]) {
1213 if (slave_kind
&& (strcmp(slave_kind
, "vrf") == 0)
1214 && !vrf_is_backend_netns()) {
1215 zif_slave_type
= ZEBRA_IF_SLAVE_VRF
;
1216 vrf_id
= *(uint32_t *)RTA_DATA(tb
[IFLA_MASTER
]);
1217 } else if (slave_kind
1218 && (strcmp(slave_kind
, "bridge") == 0)) {
1219 zif_slave_type
= ZEBRA_IF_SLAVE_BRIDGE
;
1221 *(ifindex_t
*)RTA_DATA(tb
[IFLA_MASTER
]);
1223 zif_slave_type
= ZEBRA_IF_SLAVE_OTHER
;
1225 if (vrf_is_backend_netns())
1226 vrf_id
= (vrf_id_t
)ns_id
;
1228 || !CHECK_FLAG(ifp
->status
, ZEBRA_INTERFACE_ACTIVE
)) {
1229 /* Add interface notification from kernel */
1230 if (IS_ZEBRA_DEBUG_KERNEL
)
1232 "RTM_NEWLINK ADD for %s(%u) vrf_id %u type %d "
1233 "sl_type %d master %u flags 0x%x",
1234 name
, ifi
->ifi_index
, vrf_id
, zif_type
,
1235 zif_slave_type
, bridge_ifindex
,
1239 /* unknown interface */
1240 ifp
= if_get_by_name(name
, vrf_id
, 0);
1242 /* pre-configured interface, learnt now */
1243 if (ifp
->vrf_id
!= vrf_id
)
1244 if_update_to_new_vrf(ifp
, vrf_id
);
1247 /* Update interface information. */
1248 set_ifindex(ifp
, ifi
->ifi_index
, zns
);
1249 ifp
->flags
= ifi
->ifi_flags
& 0x0000fffff;
1250 if (!tb
[IFLA_MTU
]) {
1252 "RTM_NEWLINK for interface %s(%u) without MTU set",
1253 name
, ifi
->ifi_index
);
1256 ifp
->mtu6
= ifp
->mtu
= *(int *)RTA_DATA(tb
[IFLA_MTU
]);
1258 ifp
->ptm_status
= ZEBRA_PTM_STATUS_UNKNOWN
;
1260 /* Set interface type */
1261 zebra_if_set_ziftype(ifp
, zif_type
, zif_slave_type
);
1262 if (IS_ZEBRA_IF_VRF(ifp
))
1263 SET_FLAG(ifp
->status
,
1264 ZEBRA_INTERFACE_VRF_LOOPBACK
);
1267 zebra_if_update_link(ifp
, link_ifindex
, ns_id
);
1269 netlink_interface_update_hw_addr(tb
, ifp
);
1271 /* Inform clients, install any configured addresses. */
1274 /* Extract and save L2 interface information, take
1275 * additional actions. */
1276 netlink_interface_update_l2info(
1277 ifp
, linkinfo
[IFLA_INFO_DATA
], 1);
1278 if (IS_ZEBRA_IF_BRIDGE_SLAVE(ifp
))
1279 zebra_l2if_update_bridge_slave(ifp
,
1281 if_netlink_check_ifp_instance_consistency(RTM_NEWLINK
,
1283 } else if (ifp
->vrf_id
!= vrf_id
) {
1284 /* VRF change for an interface. */
1285 if (IS_ZEBRA_DEBUG_KERNEL
)
1287 "RTM_NEWLINK vrf-change for %s(%u) "
1288 "vrf_id %u -> %u flags 0x%x",
1289 name
, ifp
->ifindex
, ifp
->vrf_id
, vrf_id
,
1292 if_handle_vrf_change(ifp
, vrf_id
);
1294 int was_bridge_slave
;
1296 /* Interface update. */
1297 if (IS_ZEBRA_DEBUG_KERNEL
)
1299 "RTM_NEWLINK update for %s(%u) "
1300 "sl_type %d master %u flags 0x%x",
1301 name
, ifp
->ifindex
, zif_slave_type
,
1302 bridge_ifindex
, ifi
->ifi_flags
);
1304 set_ifindex(ifp
, ifi
->ifi_index
, zns
);
1305 if (!tb
[IFLA_MTU
]) {
1307 "RTM_NEWLINK for interface %s(%u) without MTU set",
1308 name
, ifi
->ifi_index
);
1311 ifp
->mtu6
= ifp
->mtu
= *(int *)RTA_DATA(tb
[IFLA_MTU
]);
1314 /* Update interface type - NOTE: Only slave_type can
1316 was_bridge_slave
= IS_ZEBRA_IF_BRIDGE_SLAVE(ifp
);
1317 zebra_if_set_ziftype(ifp
, zif_type
, zif_slave_type
);
1319 netlink_interface_update_hw_addr(tb
, ifp
);
1321 if (if_is_no_ptm_operative(ifp
)) {
1322 ifp
->flags
= ifi
->ifi_flags
& 0x0000fffff;
1323 if (!if_is_no_ptm_operative(ifp
)) {
1324 if (IS_ZEBRA_DEBUG_KERNEL
)
1326 "Intf %s(%u) has gone DOWN",
1327 name
, ifp
->ifindex
);
1329 } else if (if_is_operative(ifp
)) {
1330 /* Must notify client daemons of new
1331 * interface status. */
1332 if (IS_ZEBRA_DEBUG_KERNEL
)
1334 "Intf %s(%u) PTM up, notifying clients",
1335 name
, ifp
->ifindex
);
1336 zebra_interface_up_update(ifp
);
1339 ifp
->flags
= ifi
->ifi_flags
& 0x0000fffff;
1340 if (if_is_operative(ifp
)) {
1341 if (IS_ZEBRA_DEBUG_KERNEL
)
1343 "Intf %s(%u) has come UP",
1344 name
, ifp
->ifindex
);
1349 /* Extract and save L2 interface information, take
1350 * additional actions. */
1351 netlink_interface_update_l2info(
1352 ifp
, linkinfo
[IFLA_INFO_DATA
], 0);
1353 if (IS_ZEBRA_IF_BRIDGE_SLAVE(ifp
) || was_bridge_slave
)
1354 zebra_l2if_update_bridge_slave(ifp
,
1356 if_netlink_check_ifp_instance_consistency(RTM_NEWLINK
,
1360 /* Delete interface notification from kernel */
1362 zlog_warn("RTM_DELLINK for unknown interface %s(%u)",
1363 name
, ifi
->ifi_index
);
1367 if (IS_ZEBRA_DEBUG_KERNEL
)
1368 zlog_debug("RTM_DELLINK for %s(%u)", name
,
1371 UNSET_FLAG(ifp
->status
, ZEBRA_INTERFACE_VRF_LOOPBACK
);
1373 /* Special handling for bridge or VxLAN interfaces. */
1374 if (IS_ZEBRA_IF_BRIDGE(ifp
))
1375 zebra_l2_bridge_del(ifp
);
1376 else if (IS_ZEBRA_IF_VXLAN(ifp
))
1377 zebra_l2_vxlanif_del(ifp
);
1379 if (!IS_ZEBRA_IF_VRF(ifp
))
1380 if_delete_update(ifp
);
1381 if_netlink_check_ifp_instance_consistency(RTM_DELLINK
,
1388 /* Interface information read by netlink. */
1389 void interface_list(struct zebra_ns
*zns
)
1391 interface_lookup_netlink(zns
);
1394 #endif /* GNU_LINUX */