Skip to content

Commit c55a5a9

Browse files
authored
Revert "chassis-packet: resolve the missing static routes (#14230)" (#14545)
This reverts commit a6d597a.
1 parent c62ed68 commit c55a5a9

File tree

2 files changed

+9
-21
lines changed

2 files changed

+9
-21
lines changed

files/build_templates/arp_update_vars.j2

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@
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 %}",
8-
"static_route_ifnames": "{% if STATIC_ROUTE %}{% for static_route_prefix, static_route_attr in STATIC_ROUTE.items() %}{%- if static_route_prefix -%}{{ static_route_attr['ifname'].split(',') | join(' ') + " " }}{%- 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 %}"
98
}

files/scripts/arp_update

+8-19
Original file line numberDiff line numberDiff line change
@@ -14,36 +14,25 @@ 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-
# 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'))
17+
STATIC_ROUTE_NEXTHOPS=$(echo $ARP_UPDATE_VARS | jq -r '.static_route_nexthops')
2018
# on supervisor/rp exit the script gracefully
21-
if [[ -z "$STATIC_ROUTE_NEXTHOPS" ]] || [[ -z "$STATIC_ROUTE_IFNAMES" ]]; then
19+
if [[ -z "$STATIC_ROUTE_NEXTHOPS" ]]; then
2220
logger "arp_update: exiting as no static route in packet based chassis"
2321
exit 0
2422
fi
25-
for i in ${!STATIC_ROUTE_NEXTHOPS[@]}; do
26-
nexthop="${STATIC_ROUTE_NEXTHOPS[i]}"
23+
for nexthop in $STATIC_ROUTE_NEXTHOPS; do
2724
if [[ $nexthop == *"."* ]]; then
2825
neigh_state=( $(ip -4 neigh show | grep -w $nexthop | tr -s ' ' | cut -d ' ' -f 3,4) )
2926
ping_prefix=ping
3027
elif [[ $nexthop == *":"* ]] ; then
3128
neigh_state=( $(ip -6 neigh show | grep -w $nexthop | tr -s ' ' | cut -d ' ' -f 3,4) )
3229
ping_prefix=ping6
3330
fi
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
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]}"
4736
fi
4837
done
4938

0 commit comments

Comments
 (0)