1

Is there is any way to set up priority order for multiple interfaces (more than two) for a network bond in active-backup mode?

I have 3 interfaces (I know for two interfaces I can address this problem by setting one interface as primary interface), I'm looking for any way to specify priority for each interfaces, such that when one with high priority go down, next priority will get choosed/or any way to address this issue for multiple interfaces.

1 Answer 1

0

The kernel documentation on bonding describes how to set the priority of an interface participating in a bonding interface with compatible modes:

prio

Slave priority. A higher number means higher priority. The primary slave has the highest priority. This option also follows the primary_reselect rules.

This option could only be configured via netlink, and is only valid for active-backup(1), balance-tlb (5) and balance-alb (6) mode. The valid value range is a signed 32 bit integer.

The default value is 0.

The documentation hints that:

  • it's to be done using netlink

    That means /sys can't be used for this property. The usual iproute2 tools which are using the netlink interface can be used: ip link.

  • it's to be done on a slave interface, not on the bond interface

This property can be retrieved using the -details option on interfaces set part of the bond. For example:

ip link add name b0 up type bond mode active-backup miimon 100
ip link add name s0 master b0 type veth peer name p0
# ip -details link show dev s0
4: s0@p0: <NO-CARRIER,BROADCAST,MULTICAST,SLAVE,UP,M-DOWN> mtu 1500 qdisc noqueue master b0 state LOWERLAYERDOWN mode DEFAULT group default qlen 1000
    link/ether 5e:bf:12:5b:ff:65 brd ff:ff:ff:ff:ff:ff promiscuity 0  allmulti 0 minmtu 68 maxmtu 65535 
    veth 
    bond_slave state BACKUP mii_status DOWN link_failure_count 0 perm_hwaddr 5e:bf:12:5b:ff:65 queue_id 0 prio 0 addrgenmode eui64 numtxqueues 16 numrxqueues 16 gso_max_size 65536 gso_max_segs 65535 tso_max_size 524280 tso_max_segs 65535 gro_max_size 65536 

which includes the default value: prio 0. Or also using the -json parameter and the jq command:

# ip -details -json link show dev s0 | jq '.[].linkinfo.info_slave_data.prio'
0

It can be set like this (type bond_slave is mandatory for it to accept bond-specific parameters):

ip link set dev s0 type bond_slave prio 10

Then if other factors allow for it (administratively up (ie here: ip link set dev s0 up), carrier detected (ie here: ip link set dev p0 up) etc.) it will be set as active interface as long as there's no other candidate interface available with a prio greater than this one (or set as primary which trumps prio). So with multiple different values on multiple participating interfaces it's possible to choose the order different interfaces will be chosen rather than or in addition to relying on other factors (eg: choosing primary_reselect better and having two interfaces with same prio).

As documented, I couldn't find for this example a sibling pseudo-file for the prio parameter in /sys/class/net/s0 or /sys/class/net/s0/bonding_slave.

2
  • Also couldn't find a systemd setting for prio. That's probably because it's to be set on an interface only after it's a bond slave interface. Some script will have to fix it later.
    – A.B
    Nov 20, 2023 at 2:36
  • Thanks for response @A.B.
    – ratanpreet
    Nov 20, 2023 at 18:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .