Upgrade to ifupdown2 3.0.0 with a patch to fix using broadcast addresses
In version 3.0.0, If a broadcast address is specified in /etc/network/interfaces, then when ifup is run, it will fail with an error saying `'str' object has no attribute 'packed'`. This appears to be because it expects all attributes for an interface to be "packable" into a compact binary representation. However, it doesn't actually convert the broadcast address into an IPNetwork object (other addresses are handled). Therefore, convert the broadcast address it reads in from a str to an IPNetwork object. Also explicitly specify the scope of the loopback address in /etc/network/interfaces as host scope. Otherwise, it will get added as global scope by default. As part of this, use JSON to parse ip's output instead of text, for robustness. Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
This commit is contained in:
parent
c38b95c899
commit
c8b5daed27
@ -98,7 +98,7 @@ sudo mkdir -p $FILESYSTEM_ROOT_USR_SHARE_SONIC_FIRMWARE/
|
|||||||
# Keeping it generic. It should not harm anyways.
|
# Keeping it generic. It should not harm anyways.
|
||||||
sudo mkdir -p $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
|
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 dpkg --root=$FILESYSTEM_ROOT -i $debs_path/ifupdown2_*.deb || \
|
||||||
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install -f
|
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
|
# Install Python module for psutil
|
||||||
sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip3 install 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
|
# Install SwSS SDK Python 3 package
|
||||||
# Note: the scripts will be overwritten by corresponding Python 2 package
|
# Note: the scripts will be overwritten by corresponding Python 2 package
|
||||||
SWSSSDK_PY3_WHEEL_NAME=$(basename {{swsssdk_py3_wheel_path}})
|
SWSSSDK_PY3_WHEEL_NAME=$(basename {{swsssdk_py3_wheel_path}})
|
||||||
|
@ -24,6 +24,7 @@ auto lo
|
|||||||
iface lo inet loopback
|
iface lo inet loopback
|
||||||
address 127.0.0.1
|
address 127.0.0.1
|
||||||
netmask 255.255.0.0
|
netmask 255.255.0.0
|
||||||
|
scope host
|
||||||
post-up ip addr del 127.0.0.1/8 dev lo
|
post-up ip addr del 127.0.0.1/8 dev lo
|
||||||
{% endblock loopback %}
|
{% endblock loopback %}
|
||||||
{% block mgmt_interface %}
|
{% block mgmt_interface %}
|
||||||
|
@ -13,9 +13,9 @@ fi
|
|||||||
# on Single NPU platforms we continue to use loopback adddres
|
# on Single NPU platforms we continue to use loopback adddres
|
||||||
|
|
||||||
if [[ ($NUM_ASIC -gt 1) ]]; then
|
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
|
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
|
fi
|
||||||
|
|
||||||
sonic-cfggen -d -t /usr/share/sonic/templates/rsyslog.conf.j2 -a "{\"udp_server_ip\": \"$udp_server_ip\"}" >/etc/rsyslog.conf
|
sonic-cfggen -d -t /usr/share/sonic/templates/rsyslog.conf.j2 -a "{\"udp_server_ip\": \"$udp_server_ip\"}" >/etc/rsyslog.conf
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# ifupdown2 package
|
# ifupdown2 package
|
||||||
|
|
||||||
IFUPDOWN2_VERSION = 1.2.8-1
|
IFUPDOWN2_VERSION = 3.0.0-1
|
||||||
export IFUPDOWN2_VERSION
|
export IFUPDOWN2_VERSION
|
||||||
|
|
||||||
IFUPDOWN2 = ifupdown2_$(IFUPDOWN2_VERSION)_all.deb
|
IFUPDOWN2 = ifupdown2_$(IFUPDOWN2_VERSION)_all.deb
|
||||||
|
@ -13,6 +13,14 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% :
|
|||||||
tar -z -f $(IFUPDOWN2_VERSION).tar.gz -x
|
tar -z -f $(IFUPDOWN2_VERSION).tar.gz -x
|
||||||
pushd ./ifupdown2-$(IFUPDOWN2_VERSION)
|
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
|
# Build source and Debian packages
|
||||||
dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR)
|
dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR)
|
||||||
popd
|
popd
|
||||||
|
31
src/ifupdown2/patch/0001-fix-broadcast-addr-encoding.patch
Normal file
31
src/ifupdown2/patch/0001-fix-broadcast-addr-encoding.patch
Normal file
@ -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 <sarcot@microsoft.com>
|
||||||
|
---
|
||||||
|
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:
|
1
src/ifupdown2/patch/series
Normal file
1
src/ifupdown2/patch/series
Normal file
@ -0,0 +1 @@
|
|||||||
|
0001-fix-broadcast-addr-encoding.patch
|
@ -8,6 +8,7 @@ auto lo
|
|||||||
iface lo inet loopback
|
iface lo inet loopback
|
||||||
address 127.0.0.1
|
address 127.0.0.1
|
||||||
netmask 255.255.0.0
|
netmask 255.255.0.0
|
||||||
|
scope host
|
||||||
post-up ip addr del 127.0.0.1/8 dev lo
|
post-up ip addr del 127.0.0.1/8 dev lo
|
||||||
|
|
||||||
# The management network interface
|
# The management network interface
|
||||||
|
@ -17,6 +17,7 @@ auto lo
|
|||||||
iface lo inet loopback
|
iface lo inet loopback
|
||||||
address 127.0.0.1
|
address 127.0.0.1
|
||||||
netmask 255.255.0.0
|
netmask 255.255.0.0
|
||||||
|
scope host
|
||||||
post-up ip addr del 127.0.0.1/8 dev lo
|
post-up ip addr del 127.0.0.1/8 dev lo
|
||||||
|
|
||||||
# The management network interface
|
# The management network interface
|
||||||
|
@ -8,6 +8,7 @@ auto lo
|
|||||||
iface lo inet loopback
|
iface lo inet loopback
|
||||||
address 127.0.0.1
|
address 127.0.0.1
|
||||||
netmask 255.255.0.0
|
netmask 255.255.0.0
|
||||||
|
scope host
|
||||||
post-up ip addr del 127.0.0.1/8 dev lo
|
post-up ip addr del 127.0.0.1/8 dev lo
|
||||||
|
|
||||||
# The management network interface
|
# The management network interface
|
||||||
|
@ -17,6 +17,7 @@ auto lo
|
|||||||
iface lo inet loopback
|
iface lo inet loopback
|
||||||
address 127.0.0.1
|
address 127.0.0.1
|
||||||
netmask 255.255.0.0
|
netmask 255.255.0.0
|
||||||
|
scope host
|
||||||
post-up ip addr del 127.0.0.1/8 dev lo
|
post-up ip addr del 127.0.0.1/8 dev lo
|
||||||
|
|
||||||
# The management network interface
|
# The management network interface
|
||||||
|
Loading…
Reference in New Issue
Block a user