From 215f638615fe3ab20cc97ecbd4f46ea82fb44838 Mon Sep 17 00:00:00 2001 From: Lawrence Lee Date: Mon, 17 Oct 2022 22:41:21 +0000 Subject: [PATCH] [tunnel_pkt_handler]: Skip nonexistent intfs Signed-off-by: Lawrence Lee --- dockers/docker-orchagent/tunnel_packet_handler.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/dockers/docker-orchagent/tunnel_packet_handler.py b/dockers/docker-orchagent/tunnel_packet_handler.py index 1ba29a542148..398d7956abf6 100755 --- a/dockers/docker-orchagent/tunnel_packet_handler.py +++ b/dockers/docker-orchagent/tunnel_packet_handler.py @@ -16,6 +16,7 @@ from sonic_py_common import logger as log from pyroute2 import IPRoute +from pyroute2.netlink.exceptions import NetlinkError from scapy.layers.inet import IP from scapy.layers.inet6 import IPv6 from scapy.sendrecv import AsyncSniffer @@ -115,7 +116,14 @@ def get_up_portchannels(self): portchannel_intf_names = [name for name, _ in self.portchannel_intfs] link_statuses = [] for intf in portchannel_intf_names: - status = self.netlink_api.link("get", ifname=intf) + try: + status = self.netlink_api.link("get", ifname=intf) + except NetlinkError: + # Continue if we find a non-existent interface since we don't + # need to listen on it while it's down/not created. Once it comes up, + # we will get another netlink message which will trigger this check again + logger.log_notice("Skipping non-existent interface {}".format(intf)) + continue link_statuses.append(status[0]) up_portchannels = []