Netifrc/Brctl Migration

From Gentoo Wiki
Jump to: navigation, search

These days sys-apps/iproute2 utility can manage bridges, it is superior than using the old specific utilities, among others is the net-misc/bridge-utils's brctl. Modern Linux expose bridge setting via sysfs, as result there is no need for iproute2 to support complex configuration as brctl utility, same sysfs configuration can be used for brctl based configurations as well.

brctl Migration to iproute2

The migration of brctl to iproute can be done in two phases:

  1. Migrate bridge configuration to sysfs, this can be done in stable net-misc/netifrc.
  2. Migrate bridge management into iproute2 and drop brctl usage, this requires net-misc/netifrc >= 0.4.0.

Once sysfs migration is completed, migration to iproute2 will be done as soon as netifrc supports iproute2, at this time net-misc/bridge-utils can be safely removed from system.

brctl syntax

CODE
brctl_\${NAME}="brctl-option value
brctl-option value
brctl-option port value
..."

sysfs syntax

CODE
bridge_\${sysfs_option}_\${NAME}=value
brport_\${sysfs_option}_\${NAME}=value

Migration

Old sysfs keys

In the past, bridge and brport settings were specified as variables without a prefix, now one should specify bridge_ or brport_ prefix, for example:

CODE
stp_state_br0=0

Should be specified as:

CODE
bridge_stp_state_br0=0

brctl settings

Bridge Master Interface Settings

These are setting of the bridge master device, the name of interface is the bridge name.

brctl option sysfs option notes
setageing bridge_ageing_time brctl is in seconds, sysfs is in 1/100 second, multiple by 100
setgcint N/A unsupported
stp bridge_stp_state 'on', 'yes', '1' are translated to 1 otherwise 0
setbridgeprio bridge_priority
setfd bridge_forward_delay brctl is in seconds, sysfs is in 1/100 second, multiple by 100
sethello bridge_hello_time brctl is in seconds, sysfs is in 1/100 second, multiple by 100
setmaxage bridge_max_age brctl is in seconds, sysfs is in 1/100 second, multiple by 100

Bridge Slave (Port) Settings

These are setting of the bridge slave device (port), the name of interface is the slave name.

brctl option sysfs option notes
setpathcost brport_path_cost
setportprio brport_priority
hairpin brport_hairpin_mode '1' or '0'

Examples

stp

FILE /etc/conf.d/net
brctl_br0="setfd 15
sethello 2
stp on"

Becomes:

FILE /etc/conf.d/net
bridge_forward_delay_br0=1500
bridge_hello_time_br0=200
bridge_stp_state_br0=1

port

FILE /etc/conf.d/net
brctl_br0="setbridgeprio 50
setportprio eth0 60"

Becomes:

FILE /etc/conf.d/net
bridge_priority_br0=50
brport_priority_eth0=60