Skip to content

Commit e107549

Browse files
anamehramssonicbld
authored andcommitted
chassis-packet: resolve the missing static routes (#14593)
Why I did it Fixes #14179 chassis-packet: missing arp entries for static routes causing high orchagent cpu usage It is observed that some sonic-mgmt test case calls sonic-clear arp, which clears the static arp entries as well. Orchagent or arp_update process does not try to resolve the missing arp entries after clear. How I did it arp_update should resolve the missing arp/ndp static route entries. Added code to check for missing entries and try ping if any found to resolve it. How to verify it After boot or config reload, check ipv4 and ipv4 neigh entries to make sure all static route entries are present manual validation: Use sonic-clear arp and sonic-clear ndp to clear all neighbor entries run arp_update Check for neigh entries. All entries should be present. Testing on T0 setup route/for test_static_route.py The test set the STATIC_ROUTE entry in conifg db without ifname: sonic-db-cli CONFIG_DB hmset 'STATIC_ROUTE|2.2.2.0/24' nexthop 192.168.0.18,192.168.0.25,192.168.0.23 "STATIC_ROUTE": { "2.2.2.0/24": { "nexthop": "192.168.0.18,192.168.0.25,192.168.0.23" } }, Validate that the arp_update gets the proper ARP_UPDATE_VARDS using arp_update_vars.j2 template from config db and does not crash: { "switch_type": "", "interface": "", "pc_interface" : "PortChannel101 PortChannel102 PortChannel103 PortChannel104 ", "vlan_sub_interface": "", "vlan" : "Vlan1000", "static_route_nexthops": "192.168.0.18 192.168.0.25 192.168.0.23 ", "static_route_ifnames": "" } validate route/test_static_route.py testcase pass.
1 parent 7942c92 commit e107549

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

files/build_templates/arp_update_vars.j2

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
"pc_interface" : "{% for (name, prefix) in PORTCHANNEL_INTERFACE|pfx_filter %}{% if prefix|ipv6 %}{{ name }} {% endif %}{% endfor %}",
55
"vlan_sub_interface": "{% for (name, prefix) in VLAN_SUB_INTERFACE|pfx_filter %}{% if prefix|ipv6 %}{{ name }} {% endif %}{% endfor %}",
66
"vlan" : "{% if VLAN %}{{ VLAN.keys() | join(' ') }}{% endif %}",
7-
"static_route_nexthops": "{% if STATIC_ROUTE %}{% for static_route_prefix, static_route_attr in STATIC_ROUTE.items() %}{%- if static_route_prefix -%}{{ static_route_attr['nexthop'].split(',') | join(' ') | lower + " " }}{%- endif -%}{% endfor %}{% endif %}"
7+
"static_route_nexthops": "{% if STATIC_ROUTE %}{% for static_route_prefix, static_route_attr in STATIC_ROUTE.items() %}{%- if static_route_prefix -%}{{ static_route_attr['nexthop'].split(',') | join(' ') | lower + " " }}{%- endif -%}{% endfor %}{% endif %}",
8+
"static_route_ifnames": "{% if STATIC_ROUTE %}{% for static_route_prefix, static_route_attr in STATIC_ROUTE.items() %}{%- if static_route_prefix and 'ifname' in static_route_attr -%}{{ static_route_attr['ifname'].split(',') | join(' ') + " " }}{%- endif -%}{% endfor %}{% endif %}"
89
}

files/scripts/arp_update

+19-8
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,36 @@ while /bin/true; do
1414
ARP_UPDATE_VARS=$(sonic-cfggen -d -t ${ARP_UPDATE_VARS_FILE})
1515
SWITCH_TYPE=$(echo $ARP_UPDATE_VARS | jq -r '.switch_type')
1616
if [[ "$SWITCH_TYPE" == "chassis-packet" ]]; then
17-
STATIC_ROUTE_NEXTHOPS=$(echo $ARP_UPDATE_VARS | jq -r '.static_route_nexthops')
17+
# Get array of Nexthops and ifnames. Nexthops and ifnames are mapped one to one
18+
STATIC_ROUTE_NEXTHOPS=($(echo $ARP_UPDATE_VARS | jq -r '.static_route_nexthops'))
19+
STATIC_ROUTE_IFNAMES=($(echo $ARP_UPDATE_VARS | jq -r '.static_route_ifnames'))
1820
# on supervisor/rp exit the script gracefully
19-
if [[ -z "$STATIC_ROUTE_NEXTHOPS" ]]; then
21+
if [[ -z "$STATIC_ROUTE_NEXTHOPS" ]] || [[ -z "$STATIC_ROUTE_IFNAMES" ]]; then
2022
logger "arp_update: exiting as no static route in packet based chassis"
2123
exit 0
2224
fi
23-
for nexthop in $STATIC_ROUTE_NEXTHOPS; do
25+
for i in ${!STATIC_ROUTE_NEXTHOPS[@]}; do
26+
nexthop="${STATIC_ROUTE_NEXTHOPS[i]}"
2427
if [[ $nexthop == *"."* ]]; then
2528
neigh_state=( $(ip -4 neigh show | grep -w $nexthop | tr -s ' ' | cut -d ' ' -f 3,4) )
2629
ping_prefix=ping
2730
elif [[ $nexthop == *":"* ]] ; then
2831
neigh_state=( $(ip -6 neigh show | grep -w $nexthop | tr -s ' ' | cut -d ' ' -f 3,4) )
2932
ping_prefix=ping6
3033
fi
31-
32-
if [[ "${neigh_state[1]}" == "INCOMPLETE" ]] || [[ "${neigh_state[1]}" == "FAILED" ]]; then
33-
pingcmd="timeout 0.2 $ping_prefix -I ${neigh_state[0]} -n -q -i 0 -c 1 -W 1 $nexthop >/dev/null"
34-
eval $pingcmd
35-
logger "arp_update: sttaic route nexthop not resolved, pinging $nexthop on ${neigh_state[0]}"
34+
if [[ -z "${neigh_state}" ]] || [[ "${neigh_state[1]}" == "INCOMPLETE" ]] || [[ "${neigh_state[1]}" == "FAILED" ]]; then
35+
interface="${STATIC_ROUTE_IFNAMES[i]}"
36+
if [[ -z "$interface" ]]; then
37+
# should never be here, handling just in case
38+
logger "ERR: arp_update: missing interface entry for static route $nexthop"
39+
interface=${neigh_state[0]}
40+
fi
41+
intf_up=$(ip link show $interface | grep "state UP")
42+
if [[ -n "$intf_up" ]]; then
43+
pingcmd="timeout 0.2 $ping_prefix -I ${interface} -n -q -i 0 -c 1 -W 1 $nexthop >/dev/null"
44+
eval $pingcmd
45+
logger "arp_update: static route nexthop not resolved, pinging $nexthop on ${neigh_state[0]}"
46+
fi
3647
fi
3748
done
3849

0 commit comments

Comments
 (0)