Skip to content

Commit e39967d

Browse files
author
Avtesh Singh
committed
Enable multiple ips for mlx5 devices
We need to recognize a new device type on our instances. This device type should be automatically brought up and able to query IMDS for multiple IPs as is the case for ena. To do this we: Create a separate network file for mlx5 devices and add the mlx5_core driver type to the match for policy routes. Testing: - Built and installed rpm/deb packages for AL2023/Ubuntu respectively - Launched AL2023/Ubuntu with package installed into ami - For fresh instance, install on existing instance, and reboot --> validated that we see multiple IPs and the correct MTU of 8500 for each secondary interface
1 parent a3540d3 commit e39967d

5 files changed

Lines changed: 31 additions & 4 deletions

File tree

amazon-ec2-net-utils.spec

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ make install DESTDIR=%{buildroot} PREFIX=/usr
2929

3030
%files
3131
/usr/lib/systemd/network/80-ec2.network
32+
/usr/lib/systemd/network/80-ec2-mlx5.network
3233
/usr/lib/systemd/system/policy-routes@.service
3334
/usr/lib/systemd/system/refresh-policy-routes@.service
3435
/usr/lib/systemd/system/refresh-policy-routes@.timer
@@ -64,9 +65,13 @@ net.ipv4.neigh.${iface}.retrans_time_ms=500
6465
net.ipv4.neigh.${iface}.ucast_solicit=0
6566
EOF
6667
sysctl -p /etc/sysctl.d/90-ena-tuning-${iface}.conf >/dev/null || true
68+
;;
69+
esac
70+
case $ID_NET_DRIVER in
71+
ena|ixgbevf|vif|mlx5_core)
6772
systemctl restart policy-routes@${iface}.service
6873
systemctl start refresh-policy-routes@${iface}.timer
69-
;;
74+
;;
7075
esac
7176
done
7277
}

debian/postinst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ setup_policy_routes() {
3535
unset ID_NET_DRIVER
3636
eval $(udevadm info --export --query=property /sys/class/net/$iface)
3737
case $ID_NET_DRIVER in
38-
ena|ixgbevf|vif)
38+
ena|ixgbevf|vif|mlx5_core)
3939
systemctl start policy-routes@${iface}.service
4040
systemctl start refresh-policy-routes@${iface}.timer
4141
;;

lib/lib.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,8 +458,14 @@ create_interface_config() {
458458
local network_card=$3
459459
local ether=$4
460460

461+
unset ID_NET_DRIVER
462+
eval "$(udevadm info --export --query=property /sys/class/net/"$iface")"
463+
461464
local libdir=/usr/lib/systemd/network
462465
local defconfig="${libdir}/80-ec2.network"
466+
if [ "$ID_NET_DRIVER" = "mlx5_core" ]; then
467+
defconfig="${libdir}/80-ec2-mlx5.network"
468+
fi
463469

464470
local -i retval=0
465471

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[Match]
2+
Driver=mlx5_core
3+
4+
[Network]
5+
DHCP=yes
6+
IPv6DuplicateAddressDetection=0
7+
LLMNR=no
8+
DNSDefaultRoute=yes
9+
10+
[DHCPv4]
11+
UseHostname=no
12+
UseDNS=yes
13+
UseNTP=yes
14+
UseDomains=yes
15+
UseGateway=true
16+
UseMTU=true

udev/99-vpc-policy-routes.rules

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
SUBSYSTEM=="net", ACTION=="remove", ENV{ID_NET_DRIVER}=="vif|ena|ixgbevf", RUN+="/usr/bin/systemctl disable --now refresh-policy-routes@$name.timer policy-routes@$name.service"
2-
SUBSYSTEM=="net", ACTION=="add", ENV{ID_NET_DRIVER}=="vif|ena|ixgbevf", RUN+="/usr/bin/systemctl enable --now --no-block policy-routes@$name.service"
1+
SUBSYSTEM=="net", ACTION=="remove", ENV{ID_NET_DRIVER}=="vif|ena|ixgbevf|mlx5_core", RUN+="/usr/bin/systemctl disable --now refresh-policy-routes@$name.timer policy-routes@$name.service"
2+
SUBSYSTEM=="net", ACTION=="add", ENV{ID_NET_DRIVER}=="vif|ena|ixgbevf|mlx5_core", RUN+="/usr/bin/systemctl enable --now --no-block policy-routes@$name.service"

0 commit comments

Comments
 (0)