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
;
264 #define parse_rtattr_nested(tb, max, rta) \
265 netlink_parse_rtattr((tb), (max), RTA_DATA(rta), RTA_PAYLOAD(rta))
267 static void netlink_vrf_change(struct nlmsghdr
*h
, struct rtattr
*tb
,
270 struct ifinfomsg
*ifi
;
271 struct rtattr
*linkinfo
[IFLA_INFO_MAX
+ 1];
272 struct rtattr
*attr
[IFLA_VRF_MAX
+ 1];
274 struct zebra_vrf
*zvrf
;
275 uint32_t nl_table_id
;
279 memset(linkinfo
, 0, sizeof linkinfo
);
280 parse_rtattr_nested(linkinfo
, IFLA_INFO_MAX
, tb
);
282 if (!linkinfo
[IFLA_INFO_DATA
]) {
283 if (IS_ZEBRA_DEBUG_KERNEL
)
285 "%s: IFLA_INFO_DATA missing from VRF message: %s",
290 memset(attr
, 0, sizeof attr
);
291 parse_rtattr_nested(attr
, IFLA_VRF_MAX
, linkinfo
[IFLA_INFO_DATA
]);
292 if (!attr
[IFLA_VRF_TABLE
]) {
293 if (IS_ZEBRA_DEBUG_KERNEL
)
295 "%s: IFLA_VRF_TABLE missing from VRF message: %s",
300 nl_table_id
= *(uint32_t *)RTA_DATA(attr
[IFLA_VRF_TABLE
]);
302 if (h
->nlmsg_type
== RTM_NEWLINK
) {
303 if (IS_ZEBRA_DEBUG_KERNEL
)
304 zlog_debug("RTM_NEWLINK for VRF %s(%u) table %u", name
,
305 ifi
->ifi_index
, nl_table_id
);
308 * vrf_get is implied creation if it does not exist
310 vrf
= vrf_get((vrf_id_t
)ifi
->ifi_index
,
311 name
); // It would create vrf
313 flog_err(LIB_ERR_INTERFACE
, "VRF %s id %u not created",
314 name
, ifi
->ifi_index
);
319 * This is the only place that we get the actual kernel table_id
320 * being used. We need it to set the table_id of the routes
321 * we are passing to the kernel.... And to throw some totally
322 * awesome parties. that too.
324 * At this point we *must* have a zvrf because the vrf_create
325 * callback creates one. We *must* set the table id
326 * before the vrf_enable because of( at the very least )
327 * static routes being delayed for installation until
328 * during the vrf_enable callbacks.
330 zvrf
= (struct zebra_vrf
*)vrf
->info
;
331 zvrf
->table_id
= nl_table_id
;
333 /* Enable the created VRF. */
334 if (!vrf_enable(vrf
)) {
335 flog_err(LIB_ERR_INTERFACE
,
336 "Failed to enable VRF %s id %u", name
,
341 } else // h->nlmsg_type == RTM_DELLINK
343 if (IS_ZEBRA_DEBUG_KERNEL
)
344 zlog_debug("RTM_DELLINK for VRF %s(%u)", name
,
347 vrf
= vrf_lookup_by_id((vrf_id_t
)ifi
->ifi_index
);
350 zlog_warn("%s: vrf not found", __func__
);
358 static int get_iflink_speed(struct interface
*interface
)
361 struct ethtool_cmd ecmd
;
364 const char *ifname
= interface
->name
;
366 /* initialize struct */
367 memset(&ifdata
, 0, sizeof(ifdata
));
369 /* set interface name */
370 strlcpy(ifdata
.ifr_name
, ifname
, sizeof(ifdata
.ifr_name
));
372 /* initialize ethtool interface */
373 memset(&ecmd
, 0, sizeof(ecmd
));
374 ecmd
.cmd
= ETHTOOL_GSET
; /* ETHTOOL_GLINK */
375 ifdata
.ifr_data
= (caddr_t
)&ecmd
;
377 /* use ioctl to get IP address of an interface */
378 if (zserv_privs
.change(ZPRIVS_RAISE
))
379 flog_err(LIB_ERR_PRIVILEGES
, "Can't raise privileges");
380 sd
= vrf_socket(PF_INET
, SOCK_DGRAM
, IPPROTO_IP
, interface
->vrf_id
,
383 if (IS_ZEBRA_DEBUG_KERNEL
)
384 zlog_debug("Failure to read interface %s speed: %d %s",
385 ifname
, errno
, safe_strerror(errno
));
388 /* Get the current link state for the interface */
389 rc
= vrf_ioctl(interface
->vrf_id
, sd
, SIOCETHTOOL
, (char *)&ifdata
);
390 if (zserv_privs
.change(ZPRIVS_LOWER
))
391 flog_err(LIB_ERR_PRIVILEGES
, "Can't lower privileges");
393 if (IS_ZEBRA_DEBUG_KERNEL
)
395 "IOCTL failure to read interface %s speed: %d %s",
396 ifname
, errno
, safe_strerror(errno
));
403 return (ecmd
.speed_hi
<< 16) | ecmd
.speed
;
406 uint32_t kernel_get_speed(struct interface
*ifp
)
408 return get_iflink_speed(ifp
);
411 static int netlink_extract_bridge_info(struct rtattr
*link_data
,
412 struct zebra_l2info_bridge
*bridge_info
)
414 struct rtattr
*attr
[IFLA_BR_MAX
+ 1];
416 memset(bridge_info
, 0, sizeof(*bridge_info
));
417 memset(attr
, 0, sizeof attr
);
418 parse_rtattr_nested(attr
, IFLA_BR_MAX
, link_data
);
419 if (attr
[IFLA_BR_VLAN_FILTERING
])
420 bridge_info
->vlan_aware
=
421 *(uint8_t *)RTA_DATA(attr
[IFLA_BR_VLAN_FILTERING
]);
425 static int netlink_extract_vlan_info(struct rtattr
*link_data
,
426 struct zebra_l2info_vlan
*vlan_info
)
428 struct rtattr
*attr
[IFLA_VLAN_MAX
+ 1];
431 memset(vlan_info
, 0, sizeof(*vlan_info
));
432 memset(attr
, 0, sizeof attr
);
433 parse_rtattr_nested(attr
, IFLA_VLAN_MAX
, link_data
);
434 if (!attr
[IFLA_VLAN_ID
]) {
435 if (IS_ZEBRA_DEBUG_KERNEL
)
436 zlog_debug("IFLA_VLAN_ID missing from VLAN IF message");
440 vid_in_msg
= *(vlanid_t
*)RTA_DATA(attr
[IFLA_VLAN_ID
]);
441 vlan_info
->vid
= vid_in_msg
;
445 static int netlink_extract_vxlan_info(struct rtattr
*link_data
,
446 struct zebra_l2info_vxlan
*vxl_info
)
448 struct rtattr
*attr
[IFLA_VXLAN_MAX
+ 1];
450 struct in_addr vtep_ip_in_msg
;
452 memset(vxl_info
, 0, sizeof(*vxl_info
));
453 memset(attr
, 0, sizeof attr
);
454 parse_rtattr_nested(attr
, IFLA_VXLAN_MAX
, link_data
);
455 if (!attr
[IFLA_VXLAN_ID
]) {
456 if (IS_ZEBRA_DEBUG_KERNEL
)
458 "IFLA_VXLAN_ID missing from VXLAN IF message");
462 vni_in_msg
= *(vni_t
*)RTA_DATA(attr
[IFLA_VXLAN_ID
]);
463 vxl_info
->vni
= vni_in_msg
;
464 if (!attr
[IFLA_VXLAN_LOCAL
]) {
465 if (IS_ZEBRA_DEBUG_KERNEL
)
467 "IFLA_VXLAN_LOCAL missing from VXLAN IF message");
470 *(struct in_addr
*)RTA_DATA(attr
[IFLA_VXLAN_LOCAL
]);
471 vxl_info
->vtep_ip
= vtep_ip_in_msg
;
478 * Extract and save L2 params (of interest) for an interface. When a
479 * bridge interface is added or updated, take further actions to map
480 * its members. Likewise, for VxLAN interface.
482 static void netlink_interface_update_l2info(struct interface
*ifp
,
483 struct rtattr
*link_data
, int add
)
488 if (IS_ZEBRA_IF_BRIDGE(ifp
)) {
489 struct zebra_l2info_bridge bridge_info
;
491 netlink_extract_bridge_info(link_data
, &bridge_info
);
492 zebra_l2_bridge_add_update(ifp
, &bridge_info
, add
);
493 } else if (IS_ZEBRA_IF_VLAN(ifp
)) {
494 struct zebra_l2info_vlan vlan_info
;
496 netlink_extract_vlan_info(link_data
, &vlan_info
);
497 zebra_l2_vlanif_update(ifp
, &vlan_info
);
498 } else if (IS_ZEBRA_IF_VXLAN(ifp
)) {
499 struct zebra_l2info_vxlan vxlan_info
;
501 netlink_extract_vxlan_info(link_data
, &vxlan_info
);
502 zebra_l2_vxlanif_add_update(ifp
, &vxlan_info
, add
);
506 static int netlink_bridge_interface(struct nlmsghdr
*h
, int len
, ns_id_t ns_id
,
510 struct ifinfomsg
*ifi
;
511 struct rtattr
*tb
[IFLA_MAX
+ 1];
512 struct interface
*ifp
;
513 struct rtattr
*aftb
[IFLA_BRIDGE_MAX
+ 1];
518 vlanid_t access_vlan
;
520 /* Fetch name and ifindex */
522 memset(tb
, 0, sizeof tb
);
523 netlink_parse_rtattr(tb
, IFLA_MAX
, IFLA_RTA(ifi
), len
);
525 if (tb
[IFLA_IFNAME
] == NULL
)
527 name
= (char *)RTA_DATA(tb
[IFLA_IFNAME
]);
529 /* The interface should already be known, if not discard. */
530 ifp
= if_lookup_by_index_per_ns(zebra_ns_lookup(ns_id
), ifi
->ifi_index
);
532 zlog_warn("Cannot find bridge IF %s(%u)", name
, ifi
->ifi_index
);
535 if (!IS_ZEBRA_IF_VXLAN(ifp
))
538 /* We are only interested in the access VLAN i.e., AF_SPEC */
539 if (!tb
[IFLA_AF_SPEC
])
542 /* There is a 1-to-1 mapping of VLAN to VxLAN - hence
543 * only 1 access VLAN is accepted.
545 memset(aftb
, 0, sizeof aftb
);
546 parse_rtattr_nested(aftb
, IFLA_BRIDGE_MAX
, tb
[IFLA_AF_SPEC
]);
547 if (!aftb
[IFLA_BRIDGE_VLAN_INFO
])
550 vinfo
= RTA_DATA(aftb
[IFLA_BRIDGE_VLAN_INFO
]);
551 if (!(vinfo
->flags
& BRIDGE_VLAN_INFO_PVID
))
554 access_vlan
= (vlanid_t
)vinfo
->vid
;
555 if (IS_ZEBRA_DEBUG_KERNEL
)
556 zlog_debug("Access VLAN %u for VxLAN IF %s(%u)", access_vlan
,
557 name
, ifi
->ifi_index
);
558 zebra_l2_vxlanif_update_access_vlan(ifp
, access_vlan
);
563 * Called from interface_lookup_netlink(). This function is only used
566 static int netlink_interface(struct nlmsghdr
*h
, ns_id_t ns_id
, int startup
)
569 struct ifinfomsg
*ifi
;
570 struct rtattr
*tb
[IFLA_MAX
+ 1];
571 struct rtattr
*linkinfo
[IFLA_MAX
+ 1];
572 struct interface
*ifp
;
576 char *slave_kind
= NULL
;
577 struct zebra_ns
*zns
;
578 vrf_id_t vrf_id
= VRF_DEFAULT
;
579 zebra_iftype_t zif_type
= ZEBRA_IF_OTHER
;
580 zebra_slave_iftype_t zif_slave_type
= ZEBRA_IF_SLAVE_NONE
;
581 ifindex_t bridge_ifindex
= IFINDEX_INTERNAL
;
582 ifindex_t link_ifindex
= IFINDEX_INTERNAL
;
584 zns
= zebra_ns_lookup(ns_id
);
587 if (h
->nlmsg_type
!= RTM_NEWLINK
)
590 len
= h
->nlmsg_len
- NLMSG_LENGTH(sizeof(struct ifinfomsg
));
592 zlog_err("%s: Message received from netlink is of a broken size: %d %zu",
595 (size_t)NLMSG_LENGTH(sizeof(struct ifinfomsg
)));
599 /* We are interested in some AF_BRIDGE notifications. */
600 if (ifi
->ifi_family
== AF_BRIDGE
)
601 return netlink_bridge_interface(h
, len
, ns_id
, startup
);
603 /* Looking up interface name. */
604 memset(tb
, 0, sizeof tb
);
605 memset(linkinfo
, 0, sizeof linkinfo
);
606 netlink_parse_rtattr(tb
, IFLA_MAX
, IFLA_RTA(ifi
), len
);
608 /* check for wireless messages to ignore */
609 if ((tb
[IFLA_WIRELESS
] != NULL
) && (ifi
->ifi_change
== 0)) {
610 if (IS_ZEBRA_DEBUG_KERNEL
)
611 zlog_debug("%s: ignoring IFLA_WIRELESS message",
616 if (tb
[IFLA_IFNAME
] == NULL
)
618 name
= (char *)RTA_DATA(tb
[IFLA_IFNAME
]);
620 if (tb
[IFLA_IFALIAS
])
621 desc
= (char *)RTA_DATA(tb
[IFLA_IFALIAS
]);
623 if (tb
[IFLA_LINKINFO
]) {
624 parse_rtattr_nested(linkinfo
, IFLA_INFO_MAX
, tb
[IFLA_LINKINFO
]);
626 if (linkinfo
[IFLA_INFO_KIND
])
627 kind
= RTA_DATA(linkinfo
[IFLA_INFO_KIND
]);
629 if (linkinfo
[IFLA_INFO_SLAVE_KIND
])
630 slave_kind
= RTA_DATA(linkinfo
[IFLA_INFO_SLAVE_KIND
]);
632 netlink_determine_zebra_iftype(kind
, &zif_type
);
635 /* If VRF, create the VRF structure itself. */
636 if (zif_type
== ZEBRA_IF_VRF
&& !vrf_is_backend_netns()) {
637 netlink_vrf_change(h
, tb
[IFLA_LINKINFO
], name
);
638 vrf_id
= (vrf_id_t
)ifi
->ifi_index
;
641 if (tb
[IFLA_MASTER
]) {
642 if (slave_kind
&& (strcmp(slave_kind
, "vrf") == 0)
643 && !vrf_is_backend_netns()) {
644 zif_slave_type
= ZEBRA_IF_SLAVE_VRF
;
645 vrf_id
= *(uint32_t *)RTA_DATA(tb
[IFLA_MASTER
]);
646 } else if (slave_kind
&& (strcmp(slave_kind
, "bridge") == 0)) {
647 zif_slave_type
= ZEBRA_IF_SLAVE_BRIDGE
;
649 *(ifindex_t
*)RTA_DATA(tb
[IFLA_MASTER
]);
651 zif_slave_type
= ZEBRA_IF_SLAVE_OTHER
;
653 if (vrf_is_backend_netns())
654 vrf_id
= (vrf_id_t
)ns_id
;
656 /* If linking to another interface, note it. */
658 link_ifindex
= *(ifindex_t
*)RTA_DATA(tb
[IFLA_LINK
]);
661 ifp
= if_get_by_name(name
, vrf_id
, 0);
662 set_ifindex(ifp
, ifi
->ifi_index
, zns
);
663 ifp
->flags
= ifi
->ifi_flags
& 0x0000fffff;
664 ifp
->mtu6
= ifp
->mtu
= *(uint32_t *)RTA_DATA(tb
[IFLA_MTU
]);
666 ifp
->speed
= get_iflink_speed(ifp
);
667 ifp
->ptm_status
= ZEBRA_PTM_STATUS_UNKNOWN
;
670 ifp
->desc
= XSTRDUP(MTYPE_TMP
, desc
);
672 /* Set zebra interface type */
673 zebra_if_set_ziftype(ifp
, zif_type
, zif_slave_type
);
674 if (IS_ZEBRA_IF_VRF(ifp
))
675 SET_FLAG(ifp
->status
, ZEBRA_INTERFACE_VRF_LOOPBACK
);
678 zebra_if_update_link(ifp
, link_ifindex
);
680 /* Hardware type and address. */
681 ifp
->ll_type
= netlink_to_zebra_link_type(ifi
->ifi_type
);
682 netlink_interface_update_hw_addr(tb
, ifp
);
686 /* Extract and save L2 interface information, take additional actions.
688 netlink_interface_update_l2info(ifp
, linkinfo
[IFLA_INFO_DATA
], 1);
689 if (IS_ZEBRA_IF_BRIDGE_SLAVE(ifp
))
690 zebra_l2if_update_bridge_slave(ifp
, bridge_ifindex
);
695 /* Request for specific interface or address information from the kernel */
696 static int netlink_request_intf_addr(struct zebra_ns
*zns
, int family
, int type
,
697 uint32_t filter_mask
)
701 struct ifinfomsg ifm
;
705 /* Form the request, specifying filter (rtattr) if needed. */
706 memset(&req
, 0, sizeof(req
));
707 req
.n
.nlmsg_type
= type
;
708 req
.n
.nlmsg_len
= NLMSG_LENGTH(sizeof(struct ifinfomsg
));
709 req
.ifm
.ifi_family
= family
;
711 /* Include filter, if specified. */
713 addattr32(&req
.n
, sizeof(req
), IFLA_EXT_MASK
, filter_mask
);
715 return netlink_request(&zns
->netlink_cmd
, &req
.n
);
718 /* Interface lookup by netlink socket. */
719 int interface_lookup_netlink(struct zebra_ns
*zns
)
723 /* Get interface information. */
724 ret
= netlink_request_intf_addr(zns
, AF_PACKET
, RTM_GETLINK
, 0);
727 ret
= netlink_parse_info(netlink_interface
, &zns
->netlink_cmd
, zns
, 0,
732 /* Get interface information - for bridge interfaces. */
733 ret
= netlink_request_intf_addr(zns
, AF_BRIDGE
, RTM_GETLINK
,
734 RTEXT_FILTER_BRVLAN
);
737 ret
= netlink_parse_info(netlink_interface
, &zns
->netlink_cmd
, zns
, 0,
742 /* Get interface information - for bridge interfaces. */
743 ret
= netlink_request_intf_addr(zns
, AF_BRIDGE
, RTM_GETLINK
,
744 RTEXT_FILTER_BRVLAN
);
747 ret
= netlink_parse_info(netlink_interface
, &zns
->netlink_cmd
, zns
, 0,
752 /* Get IPv4 address of the interfaces. */
753 ret
= netlink_request_intf_addr(zns
, AF_INET
, RTM_GETADDR
, 0);
756 ret
= netlink_parse_info(netlink_interface_addr
, &zns
->netlink_cmd
, zns
,
761 /* Get IPv6 address of the interfaces. */
762 ret
= netlink_request_intf_addr(zns
, AF_INET6
, RTM_GETADDR
, 0);
765 ret
= netlink_parse_info(netlink_interface_addr
, &zns
->netlink_cmd
, zns
,
773 int kernel_interface_set_master(struct interface
*master
,
774 struct interface
*slave
)
776 struct zebra_ns
*zns
= zebra_ns_lookup(NS_DEFAULT
);
780 struct ifinfomsg ifa
;
781 char buf
[NL_PKT_BUF_SIZE
];
784 memset(&req
, 0, sizeof req
);
786 req
.n
.nlmsg_len
= NLMSG_LENGTH(sizeof(struct ifinfomsg
));
787 req
.n
.nlmsg_flags
= NLM_F_REQUEST
;
788 req
.n
.nlmsg_type
= RTM_SETLINK
;
789 req
.n
.nlmsg_pid
= zns
->netlink_cmd
.snl
.nl_pid
;
791 req
.ifa
.ifi_index
= slave
->ifindex
;
793 addattr_l(&req
.n
, sizeof req
, IFLA_MASTER
, &master
->ifindex
, 4);
794 addattr_l(&req
.n
, sizeof req
, IFLA_LINK
, &slave
->ifindex
, 4);
796 return netlink_talk(netlink_talk_filter
, &req
.n
, &zns
->netlink_cmd
, zns
,
800 /* Interface address modification. */
801 static int netlink_address(int cmd
, int family
, struct interface
*ifp
,
802 struct connected
*ifc
)
809 struct ifaddrmsg ifa
;
810 char buf
[NL_PKT_BUF_SIZE
];
813 struct zebra_ns
*zns
;
815 if (vrf_is_backend_netns())
816 zns
= zebra_ns_lookup((ns_id_t
)ifp
->vrf_id
);
818 zns
= zebra_ns_lookup(NS_DEFAULT
);
820 memset(&req
, 0, sizeof req
- NL_PKT_BUF_SIZE
);
822 bytelen
= (family
== AF_INET
? 4 : 16);
824 req
.n
.nlmsg_len
= NLMSG_LENGTH(sizeof(struct ifaddrmsg
));
825 req
.n
.nlmsg_flags
= NLM_F_REQUEST
;
826 req
.n
.nlmsg_type
= cmd
;
827 req
.n
.nlmsg_pid
= zns
->netlink_cmd
.snl
.nl_pid
;
829 req
.ifa
.ifa_family
= family
;
831 req
.ifa
.ifa_index
= ifp
->ifindex
;
833 addattr_l(&req
.n
, sizeof req
, IFA_LOCAL
, &p
->u
.prefix
, bytelen
);
835 if (family
== AF_INET
) {
836 if (CONNECTED_PEER(ifc
)) {
837 p
= ifc
->destination
;
838 addattr_l(&req
.n
, sizeof req
, IFA_ADDRESS
, &p
->u
.prefix
,
840 } else if (cmd
== RTM_NEWADDR
&& ifc
->destination
) {
841 p
= ifc
->destination
;
842 addattr_l(&req
.n
, sizeof req
, IFA_BROADCAST
,
843 &p
->u
.prefix
, bytelen
);
847 /* p is now either ifc->address or ifc->destination */
848 req
.ifa
.ifa_prefixlen
= p
->prefixlen
;
850 if (CHECK_FLAG(ifc
->flags
, ZEBRA_IFA_SECONDARY
))
851 SET_FLAG(req
.ifa
.ifa_flags
, IFA_F_SECONDARY
);
854 addattr_l(&req
.n
, sizeof req
, IFA_LABEL
, ifc
->label
,
855 strlen(ifc
->label
) + 1);
857 return netlink_talk(netlink_talk_filter
, &req
.n
, &zns
->netlink_cmd
, zns
,
861 int kernel_address_add_ipv4(struct interface
*ifp
, struct connected
*ifc
)
863 return netlink_address(RTM_NEWADDR
, AF_INET
, ifp
, ifc
);
866 int kernel_address_delete_ipv4(struct interface
*ifp
, struct connected
*ifc
)
868 return netlink_address(RTM_DELADDR
, AF_INET
, ifp
, ifc
);
871 int kernel_address_add_ipv6(struct interface
*ifp
, struct connected
*ifc
)
873 return netlink_address(RTM_NEWADDR
, AF_INET6
, ifp
, ifc
);
876 int kernel_address_delete_ipv6(struct interface
*ifp
, struct connected
*ifc
)
878 return netlink_address(RTM_DELADDR
, AF_INET6
, ifp
, ifc
);
881 int netlink_interface_addr(struct nlmsghdr
*h
, ns_id_t ns_id
, int startup
)
884 struct ifaddrmsg
*ifa
;
885 struct rtattr
*tb
[IFA_MAX
+ 1];
886 struct interface
*ifp
;
891 struct zebra_ns
*zns
;
893 zns
= zebra_ns_lookup(ns_id
);
896 if (ifa
->ifa_family
!= AF_INET
&& ifa
->ifa_family
!= AF_INET6
) {
898 "Invalid address family: %u received from kernel interface addr change: %u",
899 ifa
->ifa_family
, h
->nlmsg_type
);
903 if (h
->nlmsg_type
!= RTM_NEWADDR
&& h
->nlmsg_type
!= RTM_DELADDR
)
906 len
= h
->nlmsg_len
- NLMSG_LENGTH(sizeof(struct ifaddrmsg
));
908 zlog_err("%s: Message received from netlink is of a broken size: %d %zu",
911 (size_t)NLMSG_LENGTH(sizeof(struct ifaddrmsg
)));
915 memset(tb
, 0, sizeof tb
);
916 netlink_parse_rtattr(tb
, IFA_MAX
, IFA_RTA(ifa
), len
);
918 ifp
= if_lookup_by_index_per_ns(zns
, ifa
->ifa_index
);
922 "netlink_interface_addr can't find interface by index %d",
927 if (IS_ZEBRA_DEBUG_KERNEL
) /* remove this line to see initial ifcfg */
930 zlog_debug("netlink_interface_addr %s %s flags 0x%x:",
931 nl_msg_type_to_str(h
->nlmsg_type
), ifp
->name
,
934 zlog_debug(" IFA_LOCAL %s/%d",
935 inet_ntop(ifa
->ifa_family
,
936 RTA_DATA(tb
[IFA_LOCAL
]), buf
,
940 zlog_debug(" IFA_ADDRESS %s/%d",
941 inet_ntop(ifa
->ifa_family
,
942 RTA_DATA(tb
[IFA_ADDRESS
]), buf
,
945 if (tb
[IFA_BROADCAST
])
946 zlog_debug(" IFA_BROADCAST %s/%d",
947 inet_ntop(ifa
->ifa_family
,
948 RTA_DATA(tb
[IFA_BROADCAST
]), buf
,
951 if (tb
[IFA_LABEL
] && strcmp(ifp
->name
, RTA_DATA(tb
[IFA_LABEL
])))
952 zlog_debug(" IFA_LABEL %s",
953 (char *)RTA_DATA(tb
[IFA_LABEL
]));
955 if (tb
[IFA_CACHEINFO
]) {
956 struct ifa_cacheinfo
*ci
= RTA_DATA(tb
[IFA_CACHEINFO
]);
957 zlog_debug(" IFA_CACHEINFO pref %d, valid %d",
958 ci
->ifa_prefered
, ci
->ifa_valid
);
962 /* logic copied from iproute2/ip/ipaddress.c:print_addrinfo() */
963 if (tb
[IFA_LOCAL
] == NULL
)
964 tb
[IFA_LOCAL
] = tb
[IFA_ADDRESS
];
965 if (tb
[IFA_ADDRESS
] == NULL
)
966 tb
[IFA_ADDRESS
] = tb
[IFA_LOCAL
];
968 /* local interface address */
969 addr
= (tb
[IFA_LOCAL
] ? RTA_DATA(tb
[IFA_LOCAL
]) : NULL
);
971 /* is there a peer address? */
973 && memcmp(RTA_DATA(tb
[IFA_ADDRESS
]), RTA_DATA(tb
[IFA_LOCAL
]),
974 RTA_PAYLOAD(tb
[IFA_ADDRESS
]))) {
975 broad
= RTA_DATA(tb
[IFA_ADDRESS
]);
976 SET_FLAG(flags
, ZEBRA_IFA_PEER
);
978 /* seeking a broadcast address */
979 broad
= (tb
[IFA_BROADCAST
] ? RTA_DATA(tb
[IFA_BROADCAST
])
982 /* addr is primary key, SOL if we don't have one */
984 zlog_debug("%s: NULL address", __func__
);
989 if (ifa
->ifa_flags
& IFA_F_SECONDARY
)
990 SET_FLAG(flags
, ZEBRA_IFA_SECONDARY
);
994 label
= (char *)RTA_DATA(tb
[IFA_LABEL
]);
996 if (label
&& strcmp(ifp
->name
, label
) == 0)
999 /* Register interface address to the interface. */
1000 if (ifa
->ifa_family
== AF_INET
) {
1001 if (ifa
->ifa_prefixlen
> IPV4_MAX_BITLEN
) {
1003 "Invalid prefix length: %u received from kernel interface addr change: %u",
1004 ifa
->ifa_prefixlen
, h
->nlmsg_type
);
1007 if (h
->nlmsg_type
== RTM_NEWADDR
)
1008 connected_add_ipv4(ifp
, flags
, (struct in_addr
*)addr
,
1010 (struct in_addr
*)broad
, label
);
1012 connected_delete_ipv4(
1013 ifp
, flags
, (struct in_addr
*)addr
,
1014 ifa
->ifa_prefixlen
, (struct in_addr
*)broad
);
1016 if (ifa
->ifa_family
== AF_INET6
) {
1017 if (ifa
->ifa_prefixlen
> IPV6_MAX_BITLEN
) {
1019 "Invalid prefix length: %u received from kernel interface addr change: %u",
1020 ifa
->ifa_prefixlen
, h
->nlmsg_type
);
1023 if (h
->nlmsg_type
== RTM_NEWADDR
) {
1024 /* Only consider valid addresses; we'll not get a
1026 * the kernel till IPv6 DAD has completed, but at init
1028 * does query for and will receive all addresses.
1030 if (!(ifa
->ifa_flags
1031 & (IFA_F_DADFAILED
| IFA_F_TENTATIVE
)))
1032 connected_add_ipv6(ifp
, flags
,
1033 (struct in6_addr
*)addr
,
1034 (struct in6_addr
*)broad
,
1035 ifa
->ifa_prefixlen
, label
);
1037 connected_delete_ipv6(ifp
, (struct in6_addr
*)addr
,
1038 (struct in6_addr
*)broad
,
1039 ifa
->ifa_prefixlen
);
1045 /* helper function called by if_netlink_change
1046 * to delete interfaces in case the interface moved
1049 static void if_netlink_check_ifp_instance_consistency(uint16_t cmd
,
1050 struct interface
*ifp
,
1053 struct interface
*other_ifp
;
1056 * look if interface name is also found on other netns
1057 * - only if vrf backend is netns
1058 * - do not concern lo interface
1059 * - then remove previous one
1060 * - for new link case, check found interface is not active
1062 if (!vrf_is_backend_netns() ||
1063 !strcmp(ifp
->name
, "lo"))
1065 other_ifp
= if_lookup_by_name_not_ns(ns_id
, ifp
->name
);
1068 /* because previous interface may be inactive,
1069 * interface is moved back to default vrf
1070 * then one may find the same pointer; ignore
1072 if (other_ifp
== ifp
)
1074 if ((cmd
== RTM_NEWLINK
)
1075 && (CHECK_FLAG(other_ifp
->status
, ZEBRA_INTERFACE_ACTIVE
)))
1077 if (IS_ZEBRA_DEBUG_KERNEL
&& cmd
== RTM_NEWLINK
) {
1078 zlog_debug("RTM_NEWLINK %s(%u, VRF %u) replaces %s(%u, VRF %u)\n",
1085 } else if (IS_ZEBRA_DEBUG_KERNEL
&& cmd
== RTM_DELLINK
) {
1086 zlog_debug("RTM_DELLINK %s(%u, VRF %u) is replaced by %s(%u, VRF %u)\n",
1094 /* the found interface replaces the current one
1097 if (cmd
== RTM_DELLINK
)
1100 if_delete(other_ifp
);
1101 /* the found interface is replaced by the current one
1106 int netlink_link_change(struct nlmsghdr
*h
, ns_id_t ns_id
, int startup
)
1109 struct ifinfomsg
*ifi
;
1110 struct rtattr
*tb
[IFLA_MAX
+ 1];
1111 struct rtattr
*linkinfo
[IFLA_MAX
+ 1];
1112 struct interface
*ifp
;
1116 char *slave_kind
= NULL
;
1117 struct zebra_ns
*zns
;
1118 vrf_id_t vrf_id
= VRF_DEFAULT
;
1119 zebra_iftype_t zif_type
= ZEBRA_IF_OTHER
;
1120 zebra_slave_iftype_t zif_slave_type
= ZEBRA_IF_SLAVE_NONE
;
1121 ifindex_t bridge_ifindex
= IFINDEX_INTERNAL
;
1122 ifindex_t link_ifindex
= IFINDEX_INTERNAL
;
1125 zns
= zebra_ns_lookup(ns_id
);
1126 ifi
= NLMSG_DATA(h
);
1128 /* assume if not default zns, then new VRF */
1129 if (!(h
->nlmsg_type
== RTM_NEWLINK
|| h
->nlmsg_type
== RTM_DELLINK
)) {
1130 /* If this is not link add/delete message so print warning. */
1131 zlog_warn("netlink_link_change: wrong kernel message %d",
1136 if (!(ifi
->ifi_family
== AF_UNSPEC
|| ifi
->ifi_family
== AF_BRIDGE
1137 || ifi
->ifi_family
== AF_INET6
)) {
1139 "Invalid address family: %u received from kernel link change: %u",
1140 ifi
->ifi_family
, h
->nlmsg_type
);
1144 len
= h
->nlmsg_len
- NLMSG_LENGTH(sizeof(struct ifinfomsg
));
1146 zlog_err("%s: Message received from netlink is of a broken size %d %zu",
1147 __PRETTY_FUNCTION__
, h
->nlmsg_len
,
1148 (size_t)NLMSG_LENGTH(sizeof(struct ifinfomsg
)));
1152 /* We are interested in some AF_BRIDGE notifications. */
1153 if (ifi
->ifi_family
== AF_BRIDGE
)
1154 return netlink_bridge_interface(h
, len
, ns_id
, startup
);
1156 /* Looking up interface name. */
1157 memset(tb
, 0, sizeof tb
);
1158 memset(linkinfo
, 0, sizeof linkinfo
);
1159 netlink_parse_rtattr(tb
, IFLA_MAX
, IFLA_RTA(ifi
), len
);
1161 /* check for wireless messages to ignore */
1162 if ((tb
[IFLA_WIRELESS
] != NULL
) && (ifi
->ifi_change
== 0)) {
1163 if (IS_ZEBRA_DEBUG_KERNEL
)
1164 zlog_debug("%s: ignoring IFLA_WIRELESS message",
1169 if (tb
[IFLA_IFNAME
] == NULL
)
1171 name
= (char *)RTA_DATA(tb
[IFLA_IFNAME
]);
1173 if (tb
[IFLA_LINKINFO
]) {
1174 parse_rtattr_nested(linkinfo
, IFLA_INFO_MAX
, tb
[IFLA_LINKINFO
]);
1176 if (linkinfo
[IFLA_INFO_KIND
])
1177 kind
= RTA_DATA(linkinfo
[IFLA_INFO_KIND
]);
1179 if (linkinfo
[IFLA_INFO_SLAVE_KIND
])
1180 slave_kind
= RTA_DATA(linkinfo
[IFLA_INFO_SLAVE_KIND
]);
1182 netlink_determine_zebra_iftype(kind
, &zif_type
);
1185 /* If linking to another interface, note it. */
1187 link_ifindex
= *(ifindex_t
*)RTA_DATA(tb
[IFLA_LINK
]);
1189 if (tb
[IFLA_IFALIAS
]) {
1190 desc
= (char *)RTA_DATA(tb
[IFLA_IFALIAS
]);
1193 /* If VRF, create or update the VRF structure itself. */
1194 if (zif_type
== ZEBRA_IF_VRF
&& !vrf_is_backend_netns()) {
1195 netlink_vrf_change(h
, tb
[IFLA_LINKINFO
], name
);
1196 vrf_id
= (vrf_id_t
)ifi
->ifi_index
;
1199 /* See if interface is present. */
1200 ifp
= if_lookup_by_name_per_ns(zns
, name
);
1204 XFREE(MTYPE_TMP
, ifp
->desc
);
1206 ifp
->desc
= XSTRDUP(MTYPE_TMP
, desc
);
1209 if (h
->nlmsg_type
== RTM_NEWLINK
) {
1210 if (tb
[IFLA_MASTER
]) {
1211 if (slave_kind
&& (strcmp(slave_kind
, "vrf") == 0)
1212 && !vrf_is_backend_netns()) {
1213 zif_slave_type
= ZEBRA_IF_SLAVE_VRF
;
1214 vrf_id
= *(uint32_t *)RTA_DATA(tb
[IFLA_MASTER
]);
1215 } else if (slave_kind
1216 && (strcmp(slave_kind
, "bridge") == 0)) {
1217 zif_slave_type
= ZEBRA_IF_SLAVE_BRIDGE
;
1219 *(ifindex_t
*)RTA_DATA(tb
[IFLA_MASTER
]);
1221 zif_slave_type
= ZEBRA_IF_SLAVE_OTHER
;
1223 if (vrf_is_backend_netns())
1224 vrf_id
= (vrf_id_t
)ns_id
;
1226 || !CHECK_FLAG(ifp
->status
, ZEBRA_INTERFACE_ACTIVE
)) {
1227 /* Add interface notification from kernel */
1228 if (IS_ZEBRA_DEBUG_KERNEL
)
1230 "RTM_NEWLINK ADD for %s(%u) vrf_id %u type %d "
1231 "sl_type %d master %u flags 0x%x",
1232 name
, ifi
->ifi_index
, vrf_id
, zif_type
,
1233 zif_slave_type
, bridge_ifindex
,
1237 /* unknown interface */
1238 ifp
= if_get_by_name(name
, vrf_id
, 0);
1240 /* pre-configured interface, learnt now */
1241 if (ifp
->vrf_id
!= vrf_id
)
1242 if_update_to_new_vrf(ifp
, vrf_id
);
1245 /* Update interface information. */
1246 set_ifindex(ifp
, ifi
->ifi_index
, zns
);
1247 ifp
->flags
= ifi
->ifi_flags
& 0x0000fffff;
1248 if (!tb
[IFLA_MTU
]) {
1250 "RTM_NEWLINK for interface %s(%u) without MTU set",
1251 name
, ifi
->ifi_index
);
1254 ifp
->mtu6
= ifp
->mtu
= *(int *)RTA_DATA(tb
[IFLA_MTU
]);
1256 ifp
->ptm_status
= ZEBRA_PTM_STATUS_UNKNOWN
;
1258 /* Set interface type */
1259 zebra_if_set_ziftype(ifp
, zif_type
, zif_slave_type
);
1260 if (IS_ZEBRA_IF_VRF(ifp
))
1261 SET_FLAG(ifp
->status
,
1262 ZEBRA_INTERFACE_VRF_LOOPBACK
);
1265 zebra_if_update_link(ifp
, link_ifindex
);
1267 netlink_interface_update_hw_addr(tb
, ifp
);
1269 /* Inform clients, install any configured addresses. */
1272 /* Extract and save L2 interface information, take
1273 * additional actions. */
1274 netlink_interface_update_l2info(
1275 ifp
, linkinfo
[IFLA_INFO_DATA
], 1);
1276 if (IS_ZEBRA_IF_BRIDGE_SLAVE(ifp
))
1277 zebra_l2if_update_bridge_slave(ifp
,
1279 if_netlink_check_ifp_instance_consistency(RTM_NEWLINK
,
1281 } else if (ifp
->vrf_id
!= vrf_id
) {
1282 /* VRF change for an interface. */
1283 if (IS_ZEBRA_DEBUG_KERNEL
)
1285 "RTM_NEWLINK vrf-change for %s(%u) "
1286 "vrf_id %u -> %u flags 0x%x",
1287 name
, ifp
->ifindex
, ifp
->vrf_id
, vrf_id
,
1290 if_handle_vrf_change(ifp
, vrf_id
);
1292 int was_bridge_slave
;
1294 /* Interface update. */
1295 if (IS_ZEBRA_DEBUG_KERNEL
)
1297 "RTM_NEWLINK update for %s(%u) "
1298 "sl_type %d master %u flags 0x%x",
1299 name
, ifp
->ifindex
, zif_slave_type
,
1300 bridge_ifindex
, ifi
->ifi_flags
);
1302 set_ifindex(ifp
, ifi
->ifi_index
, zns
);
1303 if (!tb
[IFLA_MTU
]) {
1305 "RTM_NEWLINK for interface %s(%u) without MTU set",
1306 name
, ifi
->ifi_index
);
1309 ifp
->mtu6
= ifp
->mtu
= *(int *)RTA_DATA(tb
[IFLA_MTU
]);
1312 /* Update interface type - NOTE: Only slave_type can
1314 was_bridge_slave
= IS_ZEBRA_IF_BRIDGE_SLAVE(ifp
);
1315 zebra_if_set_ziftype(ifp
, zif_type
, zif_slave_type
);
1317 netlink_interface_update_hw_addr(tb
, ifp
);
1319 if (if_is_no_ptm_operative(ifp
)) {
1320 ifp
->flags
= ifi
->ifi_flags
& 0x0000fffff;
1321 if (!if_is_no_ptm_operative(ifp
)) {
1322 if (IS_ZEBRA_DEBUG_KERNEL
)
1324 "Intf %s(%u) has gone DOWN",
1325 name
, ifp
->ifindex
);
1327 } else if (if_is_operative(ifp
)) {
1328 /* Must notify client daemons of new
1329 * interface status. */
1330 if (IS_ZEBRA_DEBUG_KERNEL
)
1332 "Intf %s(%u) PTM up, notifying clients",
1333 name
, ifp
->ifindex
);
1334 zebra_interface_up_update(ifp
);
1337 ifp
->flags
= ifi
->ifi_flags
& 0x0000fffff;
1338 if (if_is_operative(ifp
)) {
1339 if (IS_ZEBRA_DEBUG_KERNEL
)
1341 "Intf %s(%u) has come UP",
1342 name
, ifp
->ifindex
);
1347 /* Extract and save L2 interface information, take
1348 * additional actions. */
1349 netlink_interface_update_l2info(
1350 ifp
, linkinfo
[IFLA_INFO_DATA
], 0);
1351 if (IS_ZEBRA_IF_BRIDGE_SLAVE(ifp
) || was_bridge_slave
)
1352 zebra_l2if_update_bridge_slave(ifp
,
1354 if_netlink_check_ifp_instance_consistency(RTM_NEWLINK
,
1358 /* Delete interface notification from kernel */
1360 zlog_warn("RTM_DELLINK for unknown interface %s(%u)",
1361 name
, ifi
->ifi_index
);
1365 if (IS_ZEBRA_DEBUG_KERNEL
)
1366 zlog_debug("RTM_DELLINK for %s(%u)", name
,
1369 UNSET_FLAG(ifp
->status
, ZEBRA_INTERFACE_VRF_LOOPBACK
);
1371 /* Special handling for bridge or VxLAN interfaces. */
1372 if (IS_ZEBRA_IF_BRIDGE(ifp
))
1373 zebra_l2_bridge_del(ifp
);
1374 else if (IS_ZEBRA_IF_VXLAN(ifp
))
1375 zebra_l2_vxlanif_del(ifp
);
1377 if (!IS_ZEBRA_IF_VRF(ifp
))
1378 if_delete_update(ifp
);
1379 if_netlink_check_ifp_instance_consistency(RTM_DELLINK
,
1386 /* Interface information read by netlink. */
1387 void interface_list(struct zebra_ns
*zns
)
1389 interface_lookup_netlink(zns
);
1392 #endif /* GNU_LINUX */