Skip to content

Commit f9578d9

Browse files
authored
[202012][LLDPD] fix to port remove and immediately create problem (#12467)
Why I did it Cherry pick #9519. when we remove a port and add it back immediately - lldp is keep failing warning message keeps appearing: [WARN/lldp] unable to send packet on real device for Ethernet4: No such device or address How I did it on delete link events it will immediately execute delete without using aggregate events mechanism. How to verify it Run autorestart/test_container_autorestart.py in sonic-mgmt repo Or manual test steps: sudo config feature autorestart swss disabled docker exec swss supervisorctl status docker exec swss kill -SIGKILL 111(orchagent) docker inspect -f {{.State.Running}} swss => make sure swss is running docker exec swss supervisorctl start orchagent Signed-off-by: Zhaohui Sun <[email protected]>
1 parent bafbfb5 commit f9578d9

File tree

2 files changed

+83
-0
lines changed

2 files changed

+83
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
diff --git a/src/daemon/interfaces-linux.c b/src/daemon/interfaces-linux.c
2+
index a8280c8..a51440a 100644
3+
--- a/src/daemon/interfaces-linux.c
4+
+++ b/src/daemon/interfaces-linux.c
5+
@@ -775,7 +775,7 @@ iflinux_handle_bond(struct lldpd *cfg, struct interfaces_device_list *interfaces
6+
created = 1;
7+
}
8+
if (hardware->h_flags) continue;
9+
- if (hardware->h_ops != &bond_ops) {
10+
+ if (hardware->h_ops != &bond_ops || hardware->h_ifindex_changed) {
11+
if (!created) {
12+
log_debug("interfaces",
13+
"bond %s is converted from another type of interface",
14+
@@ -794,7 +794,7 @@ iflinux_handle_bond(struct lldpd *cfg, struct interfaces_device_list *interfaces
15+
} else bmaster = hardware->h_data;
16+
bmaster->index = master->index;
17+
strlcpy(bmaster->name, master->name, IFNAMSIZ);
18+
- if (hardware->h_ops != &bond_ops) {
19+
+ if (hardware->h_ops != &bond_ops || hardware->h_ifindex_changed) {
20+
if (iface_bond_init(cfg, hardware) != 0) {
21+
log_warn("interfaces", "unable to initialize %s",
22+
hardware->h_ifname);
23+
diff --git a/src/daemon/interfaces.c b/src/daemon/interfaces.c
24+
index 3c6c255..58db018 100644
25+
--- a/src/daemon/interfaces.c
26+
+++ b/src/daemon/interfaces.c
27+
@@ -623,7 +623,7 @@ interfaces_helper_physical(struct lldpd *cfg,
28+
}
29+
if (hardware->h_flags)
30+
continue;
31+
- if (hardware->h_ops != ops) {
32+
+ if (hardware->h_ops != ops || hardware->h_ifindex_changed) {
33+
if (!created) {
34+
log_debug("interfaces",
35+
"interface %s is converted from another type of interface",
36+
diff --git a/src/daemon/lldpd.c b/src/daemon/lldpd.c
37+
index 1d92dd3..f3e82e5 100644
38+
--- a/src/daemon/lldpd.c
39+
+++ b/src/daemon/lldpd.c
40+
@@ -147,6 +147,12 @@ lldpd_get_hardware(struct lldpd *cfg, char *name, int index)
41+
TAILQ_FOREACH(hardware, &cfg->g_hardware, h_entries) {
42+
if (strcmp(hardware->h_ifname, name) == 0) {
43+
if (hardware->h_flags == 0) {
44+
+ if (hardware->h_ifindex != 0 &&
45+
+ hardware->h_ifindex != index) {
46+
+ log_debug("interfaces", "%s changed index: from %d to %d",
47+
+ hardware->h_ifname, hardware->h_ifindex, index);
48+
+ hardware->h_ifindex_changed = 1;
49+
+ }
50+
hardware->h_ifindex = index;
51+
break;
52+
}
53+
@@ -392,7 +398,8 @@ lldpd_reset_timer(struct lldpd *cfg)
54+
}
55+
56+
/* Compare with the previous value */
57+
- if (hardware->h_lport_previous &&
58+
+ if (!hardware->h_ifindex_changed &&
59+
+ hardware->h_lport_previous &&
60+
output_len == hardware->h_lport_previous_len &&
61+
!memcmp(output, hardware->h_lport_previous, output_len)) {
62+
log_debug("localchassis",
63+
@@ -402,6 +409,7 @@ lldpd_reset_timer(struct lldpd *cfg)
64+
log_debug("localchassis",
65+
"change detected for port %s, resetting its timer",
66+
hardware->h_ifname);
67+
+ hardware->h_ifindex_changed = 0;
68+
levent_schedule_pdu(hardware);
69+
}
70+
71+
diff --git a/src/lldpd-structs.h b/src/lldpd-structs.h
72+
index f6b03d7..213f306 100644
73+
--- a/src/lldpd-structs.h
74+
+++ b/src/lldpd-structs.h
75+
@@ -454,6 +454,7 @@ struct lldpd_hardware {
76+
removed if this is left
77+
to 0. */
78+
int h_ifindex; /* Interface index, used by SNMP */
79+
+ int h_ifindex_changed; /* Interface index has changed */
80+
char h_ifname[IFNAMSIZ]; /* Should be unique */
81+
u_int8_t h_lladdr[ETHER_ADDR_LEN];
82+

src/lldpd/patch/series

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
0007-lib-fix-memory-leak-when-handling-I-O.patch
66
0010-Ported-fix-for-length-exceeded-from-lldp-community.patch
77
0011-fix-med-location-len.patch
8+
0012-fix-recreate-socket-on-ifindex-change.patch

0 commit comments

Comments
 (0)