diff --git a/files/build_templates/sonic_debian_extension.j2 b/files/build_templates/sonic_debian_extension.j2 index 59232f1b75..0d5b895cac 100644 --- a/files/build_templates/sonic_debian_extension.j2 +++ b/files/build_templates/sonic_debian_extension.j2 @@ -98,7 +98,7 @@ sudo mkdir -p $FILESYSTEM_ROOT_USR_SHARE_SONIC_FIRMWARE/ # Keeping it generic. It should not harm anyways. sudo mkdir -p $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM -# Install a more recent version of ifupdown2 (and its dependencies via 'apt-get -y install -f') +# Install a patched version of ifupdown2 (and its dependencies via 'apt-get -y install -f') sudo dpkg --root=$FILESYSTEM_ROOT -i $debs_path/ifupdown2_*.deb || \ sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install -f @@ -139,6 +139,10 @@ sudo rm -rf $FILESYSTEM_ROOT/$REDIS_DUMP_LOAD_PY2_WHEEL_NAME # Install Python module for psutil sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip3 install psutil +# Install Python module for ipaddr +sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip2 install ipaddr +sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip3 install ipaddr + # Install SwSS SDK Python 3 package # Note: the scripts will be overwritten by corresponding Python 2 package SWSSSDK_PY3_WHEEL_NAME=$(basename {{swsssdk_py3_wheel_path}}) diff --git a/files/image_config/interfaces/interfaces.j2 b/files/image_config/interfaces/interfaces.j2 index 98e43dd13b..1e554e4ed7 100644 --- a/files/image_config/interfaces/interfaces.j2 +++ b/files/image_config/interfaces/interfaces.j2 @@ -24,6 +24,7 @@ auto lo iface lo inet loopback address 127.0.0.1 netmask 255.255.0.0 + scope host post-up ip addr del 127.0.0.1/8 dev lo {% endblock loopback %} {% block mgmt_interface %} diff --git a/files/image_config/rsyslog/rsyslog-config.sh b/files/image_config/rsyslog/rsyslog-config.sh index 26767d84fb..f3895302e0 100755 --- a/files/image_config/rsyslog/rsyslog-config.sh +++ b/files/image_config/rsyslog/rsyslog-config.sh @@ -13,9 +13,9 @@ fi # on Single NPU platforms we continue to use loopback adddres if [[ ($NUM_ASIC -gt 1) ]]; then - udp_server_ip=$(ip -o -4 addr list docker0 | awk '{print $4}' | cut -d/ -f1) + udp_server_ip=$(ip -j -4 addr list docker0 | jq -r -M '.[0].addr_info[0].local') else - udp_server_ip=$(ip -o -4 addr list lo scope host | awk '{print $4}' | cut -d/ -f1) + udp_server_ip=$(ip -j -4 addr list lo scope host | jq -r -M '.[0].addr_info[0].local') fi sonic-cfggen -d -t /usr/share/sonic/templates/rsyslog.conf.j2 -a "{\"udp_server_ip\": \"$udp_server_ip\"}" >/etc/rsyslog.conf diff --git a/rules/ifupdown2.mk b/rules/ifupdown2.mk index f81facd8ff..0a7abd7b2f 100644 --- a/rules/ifupdown2.mk +++ b/rules/ifupdown2.mk @@ -1,6 +1,6 @@ # ifupdown2 package -IFUPDOWN2_VERSION = 1.2.8-1 +IFUPDOWN2_VERSION = 3.0.0-1 export IFUPDOWN2_VERSION IFUPDOWN2 = ifupdown2_$(IFUPDOWN2_VERSION)_all.deb diff --git a/src/ifupdown2/Makefile b/src/ifupdown2/Makefile index 89228bedaf..ed6f6b5499 100644 --- a/src/ifupdown2/Makefile +++ b/src/ifupdown2/Makefile @@ -13,6 +13,14 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : tar -z -f $(IFUPDOWN2_VERSION).tar.gz -x pushd ./ifupdown2-$(IFUPDOWN2_VERSION) + git init + git add -f * + git commit -m "unmodified ifupdown2 source" + + # Apply patch series + stg init + stg import -s ../patch/series + # Build source and Debian packages dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) popd diff --git a/src/ifupdown2/patch/0001-fix-broadcast-addr-encoding.patch b/src/ifupdown2/patch/0001-fix-broadcast-addr-encoding.patch new file mode 100644 index 0000000000..43ccbf0c63 --- /dev/null +++ b/src/ifupdown2/patch/0001-fix-broadcast-addr-encoding.patch @@ -0,0 +1,31 @@ +Fix reading and using broadcast address + +When reading the broadcast address, convert it to an IPNetwork object, +so that it can be encoded/packed later. + +From: Saikrishna Arcot +--- + ifupdown2/addons/address.py | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/ifupdown2/addons/address.py b/ifupdown2/addons/address.py +index 8b99b25..2ca41fc 100644 +--- a/ifupdown2/addons/address.py ++++ b/ifupdown2/addons/address.py +@@ -441,11 +441,15 @@ class address(Addon, moduleBase): + else: + addr_obj = ipnetwork.IPNetwork(addr) + +- for attr_name in ("broadcast", "scope", "preferred-lifetime"): ++ for attr_name in ("scope", "preferred-lifetime"): + attr_value = ifaceobj.get_attr_value_n(attr_name, index) + if attr_value: + addr_attributes[attr_name] = attr_value + ++ broadcast = ifaceobj.get_attr_value_n("broadcast", index) ++ if broadcast: ++ addr_attributes["broadcast"] = ipnetwork.IPNetwork(broadcast) ++ + pointopoint = ifaceobj.get_attr_value_n("pointopoint", index) + try: + if pointopoint: diff --git a/src/ifupdown2/patch/series b/src/ifupdown2/patch/series new file mode 100644 index 0000000000..48fb11e8c3 --- /dev/null +++ b/src/ifupdown2/patch/series @@ -0,0 +1 @@ +0001-fix-broadcast-addr-encoding.patch diff --git a/src/sonic-config-engine/tests/sample_output/py2/interfaces b/src/sonic-config-engine/tests/sample_output/py2/interfaces index 6e952d6f71..360ecf7b13 100644 --- a/src/sonic-config-engine/tests/sample_output/py2/interfaces +++ b/src/sonic-config-engine/tests/sample_output/py2/interfaces @@ -8,6 +8,7 @@ auto lo iface lo inet loopback address 127.0.0.1 netmask 255.255.0.0 + scope host post-up ip addr del 127.0.0.1/8 dev lo # The management network interface diff --git a/src/sonic-config-engine/tests/sample_output/py2/mvrf_interfaces b/src/sonic-config-engine/tests/sample_output/py2/mvrf_interfaces index 9e5c8a4261..6143d7ba8c 100644 --- a/src/sonic-config-engine/tests/sample_output/py2/mvrf_interfaces +++ b/src/sonic-config-engine/tests/sample_output/py2/mvrf_interfaces @@ -17,6 +17,7 @@ auto lo iface lo inet loopback address 127.0.0.1 netmask 255.255.0.0 + scope host post-up ip addr del 127.0.0.1/8 dev lo # The management network interface diff --git a/src/sonic-config-engine/tests/sample_output/py3/interfaces b/src/sonic-config-engine/tests/sample_output/py3/interfaces index 6e952d6f71..360ecf7b13 100644 --- a/src/sonic-config-engine/tests/sample_output/py3/interfaces +++ b/src/sonic-config-engine/tests/sample_output/py3/interfaces @@ -8,6 +8,7 @@ auto lo iface lo inet loopback address 127.0.0.1 netmask 255.255.0.0 + scope host post-up ip addr del 127.0.0.1/8 dev lo # The management network interface diff --git a/src/sonic-config-engine/tests/sample_output/py3/mvrf_interfaces b/src/sonic-config-engine/tests/sample_output/py3/mvrf_interfaces index 9e5c8a4261..6143d7ba8c 100644 --- a/src/sonic-config-engine/tests/sample_output/py3/mvrf_interfaces +++ b/src/sonic-config-engine/tests/sample_output/py3/mvrf_interfaces @@ -17,6 +17,7 @@ auto lo iface lo inet loopback address 127.0.0.1 netmask 255.255.0.0 + scope host post-up ip addr del 127.0.0.1/8 dev lo # The management network interface