Netifrc/Brctl Migration

From Gentoo Wiki
Jump to:navigation Jump to: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 to iproute2 migration

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

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)

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

Various bridge attributes can be verified after porting the configuration by reading: /sys/class/net/br0/bridge/*

root #ls /sys/class/net/br0/bridge
ageing_time      max_age                            multicast_snooping                stp_state
bridge_id        multicast_igmp_version             multicast_startup_query_count     tcn_timer
default_pvid     multicast_last_member_count        multicast_startup_query_interval  topology_change
flush            multicast_last_member_interval     multicast_stats_enabled           topology_change_detected
forward_delay    multicast_membership_interval      nf_call_arptables                 topology_change_timer
gc_timer         multicast_mld_version              nf_call_ip6tables                 vlan_filtering
group_addr       multicast_querier                  nf_call_iptables                  vlan_protocol
group_fwd_mask   multicast_querier_interval         no_linklocal_learn                vlan_stats_enabled
hash_elasticity  multicast_query_interval           priority                          vlan_stats_per_port
hash_max         multicast_query_response_interval  root_id
hello_time       multicast_query_use_ifaddr         root_path_cost
hello_timer      multicast_router                   root_port


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