Skip to content

Commit 11c2e9e

Browse files
Pavlo Yadvichuklguohan
Pavlo Yadvichuk
authored andcommitted
[barefoot]: Allow configuration of platform-specific interfaces used for internal purposes (#2631)
- Why it is required since SONiC master switches ifupdown package to the new implementation (ifupdown2), it is required to change the configuration of a platform-specific interface for wedge100bf_32x and wedge100bf_65x platforms (bc of ifupdown2 doesn't support auto mode for inet6 protocol). Also, need to make some refactoring and remove if platform == smth then.. from the system level scripts. - What I did removed customization of /usr/bin/interfaces-config.sh explicitly created directory /etc/network/interfaces.d added "source" to the /etc/network/interfaces generation template (to include platform-specific interfaces processing) added platform-specific interfaces config itself (for wedge100bf_32x and wedge100bf_65x) fixed testcase in sonic-config-engine - How to verify it build image for wedge100bf_32x perform sudo config reload -y on new installation check the correct configuration of usb0 interface - Description for the changelog Allow configuration of platform-specific interfaces
1 parent 2bb5400 commit 11c2e9e

File tree

8 files changed

+21
-12
lines changed

8 files changed

+21
-12
lines changed

files/build_templates/sonic_debian_extension.j2

+1
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ sudo cp $IMAGE_CONFIGS/interfaces/*.j2 $FILESYSTEM_ROOT_USR_SHARE_SONIC_TEMPLATE
165165

166166
# Copy initial interfaces configuration file, will be overwritten on first boot
167167
sudo cp $IMAGE_CONFIGS/interfaces/init_interfaces $FILESYSTEM_ROOT/etc/network/interfaces
168+
sudo mkdir -p $FILESYSTEM_ROOT/etc/network/interfaces.d
168169

169170
# Copy hostcfgd files
170171
sudo cp $IMAGE_CONFIGS/hostcfgd/hostcfgd.service $FILESYSTEM_ROOT/etc/systemd/system/

files/image_config/interfaces/interfaces-config.sh

-12
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,6 @@ ifdown --force eth0
44

55
sonic-cfggen -d -t /usr/share/sonic/templates/interfaces.j2 > /etc/network/interfaces
66

7-
# Add usb0 interface for bfn platforms
8-
platform=$(sonic-cfggen -H -v 'DEVICE_METADATA["localhost"]["platform"]')
9-
if [[ "$platform" == "x86_64-accton_wedge100bf_32x-r0" || "$platform" == "x86_64-accton_wedge100bf_65x-r0" ]]; then
10-
cat <<'EOF' >> /etc/network/interfaces
11-
# BMC interface
12-
auto usb0
13-
allow-hotplug usb0
14-
iface usb0 inet6 auto
15-
up ifconfig usb0 txqueuelen 64
16-
EOF
17-
fi
18-
197
[ -f /var/run/dhclient.eth0.pid ] && kill `cat /var/run/dhclient.eth0.pid` && rm -f /var/run/dhclient.eth0.pid
208

219
systemctl restart networking

files/image_config/interfaces/interfaces.j2

+2
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,6 @@ iface eth0 {{ 'inet' if prefix | ipv4 else 'inet6' }} static
4747
iface eth0 inet dhcp
4848
{% endif %}
4949
#
50+
source /etc/network/interfaces.d/*
51+
#
5052
{% endblock mgmt_interface %}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# BMC interface
2+
auto usb0
3+
allow-hotplug usb0
4+
iface usb0 inet6
5+
up ifconfig usb0 txqueuelen 64

platform/barefoot/sonic-platform-modules-bfn-montara/debian/rules

+3
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22

33
PACKAGE_NAME := sonic-platform-modules-bfn-montara
44
SCRIPT_SRC := $(shell pwd)/scripts
5+
CONFIGS_SRC := $(shell pwd)/configs
56

67
%:
78
dh $@
89

910
override_dh_auto_install:
1011
dh_installdirs -p$(PACKAGE_NAME) usr/local/bin
1112
cp -r $(SCRIPT_SRC)/* debian/$(PACKAGE_NAME)/usr/local/bin
13+
dh_installdirs -p$(PACKAGE_NAME) etc/network/interfaces.d/
14+
cp -r $(CONFIGS_SRC)/network/interfaces.d/* debian/$(PACKAGE_NAME)/etc/network/interfaces.d/
1215

1316
override_dh_usrlocal:
1417

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# BMC interface
2+
auto usb0
3+
allow-hotplug usb0
4+
iface usb0 inet6
5+
up ifconfig usb0 txqueuelen 64

platform/barefoot/sonic-platform-modules-bfn/debian/rules

+3
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22

33
PACKAGE_NAME := sonic-platform-modules-bfn
44
SCRIPT_SRC := $(shell pwd)/scripts
5+
CONFIGS_SRC := $(shell pwd)/configs
56

67
%:
78
dh $@
89

910
override_dh_auto_install:
1011
dh_installdirs -p$(PACKAGE_NAME) usr/local/bin
1112
cp -r $(SCRIPT_SRC)/* debian/$(PACKAGE_NAME)/usr/local/bin
13+
dh_installdirs -p$(PACKAGE_NAME) etc/network/interfaces.d/
14+
cp -r $(CONFIGS_SRC)/network/interfaces.d/* debian/$(PACKAGE_NAME)/etc/network/interfaces.d/
1215

1316
override_dh_usrlocal:
1417

src/sonic-config-engine/tests/sample_output/interfaces

+2
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,6 @@ iface eth0 inet6 static
4747
down ip -6 route delete 2603:10e2:0:2902::/64 dev eth0 table default
4848
down ip -6 rule delete from 2603:10e2:0:2902::8/128 table default
4949
#
50+
source /etc/network/interfaces.d/*
51+
#
5052

0 commit comments

Comments
 (0)