Commit 1aabc6c
committed
portmgrd: prevent runtime failure in setting MTU on portchannel member (PR sonic-net#3432)
Prevent setting the PORT MTU on PortChannel members as it will likely fail
and cause portmgrd to exit (The PortChannel itself is where the MTU gets set,
not the PORT). The current code is setting a default value for an MTU (9100)
even when its a PortChannel member, so this patch prevents that default value
from being set. Also if a user were to incorrectly specify an MTU on a Port
that is a member of the port channel via `config_db.json` this too would bring
down portmgrd, so catch that and just emit a warning instead.
The YANG model does NOT support checking for this.
In order to not add much overhead for large port count systems, we are also
lazily caching portchannel members and only using that cache on a new port
being brought up or on failure to set an MTU.
The current code *always* attempts to set an MTU on the PORT by setting a
default here:
https://github.com/sonic-net/sonic-swss/blob/c20902f3195b5bf8a941045e131aa1b863b69fd0/cfgmgr/portmgr.cpp#L163-L172
Then applies it here:
https://github.com/sonic-net/sonic-swss/blob/c20902f3195b5bf8a941045e131aa1b863b69fd0/cfgmgr/portmgr.cpp#L222-L226
So it isn't crashing because the user configured the MTU in the PORT config,
but rather because it is done by default when the port is created. (But it
also would crash if a user set an MTU on a port which is bad since YANG doesn't
do anything to prevent this).
**NOTE**: this only appears to crash on a freshly loaded config at boot, if you
take an existing running configuration and modify it to add a portchannel it
works since the PORT is already provisioned so the default MTU setting path
isn't taken in the above referenced code.
This regression was caused by 8b99543 ... but
just reverting that patch isn't the right solution. The startup logic does not
appear to be proper as it tries to set a default MTU regardless if its valid
to do so for the port or not.
Logs show this issue which is a critical failure causing the entire switch to
go down:
```
2024 Dec 17 19:26:20.964259 sw1 INFO swss#supervisord: portmgrd RTNETLINK answers: Operation not permitted
2024 Dec 17 19:26:20.965353 sw1 ERR swss#portmgrd: :- main: Runtime error: /sbin/ip link set dev "Ethernet0" mtu "9100" :
2024 Dec 17 19:26:20.967020 sw1 INFO swss#supervisord 2024-12-17 19:26:20,966 WARN exited: portmgrd (exit status 255; not expected)
```
Signed-off-by: Brad House (@bradh352)1 parent 62cf8ae commit 1aabc6c
3 files changed
Lines changed: 107 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
25 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
26 | 60 | | |
27 | 61 | | |
28 | 62 | | |
| |||
43 | 77 | | |
44 | 78 | | |
45 | 79 | | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
46 | 86 | | |
47 | 87 | | |
48 | 88 | | |
| |||
128 | 168 | | |
129 | 169 | | |
130 | 170 | | |
| 171 | + | |
131 | 172 | | |
132 | 173 | | |
133 | 174 | | |
134 | 175 | | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
135 | 182 | | |
136 | 183 | | |
137 | 184 | | |
| |||
156 | 203 | | |
157 | 204 | | |
158 | 205 | | |
| 206 | + | |
159 | 207 | | |
160 | 208 | | |
161 | 209 | | |
| |||
167 | 215 | | |
168 | 216 | | |
169 | 217 | | |
170 | | - | |
171 | 218 | | |
172 | 219 | | |
173 | 220 | | |
| |||
181 | 228 | | |
182 | 229 | | |
183 | 230 | | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
184 | 235 | | |
185 | 236 | | |
186 | 237 | | |
| |||
192 | 243 | | |
193 | 244 | | |
194 | 245 | | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
195 | 251 | | |
196 | 252 | | |
197 | 253 | | |
| |||
221 | 277 | | |
222 | 278 | | |
223 | 279 | | |
224 | | - | |
225 | 280 | | |
| 281 | + | |
226 | 282 | | |
227 | 283 | | |
228 | 284 | | |
229 | 285 | | |
230 | | - | |
231 | 286 | | |
| 287 | + | |
232 | 288 | | |
233 | 289 | | |
234 | 290 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
464 | 464 | | |
465 | 465 | | |
466 | 466 | | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
467 | 512 | | |
468 | 513 | | |
469 | 514 | | |
| |||
0 commit comments