BRIDGE(3)                                               BRIDGE(3)

     NAME
          bridge - IP Ethernet bridge

     SYNOPSIS
          bind -a #Bb /net

          /net/bridgeb/ctl
          /net/bridgeb/cache
          /net/bridgeb/log
          /net/bridgeb/stats
          /net/bridgeb/n
          /net/bridgeb/n/ctl
          /net/bridgeb/n/local
          /net/bridgeb/n/status

     DESCRIPTION
          The bridge device bridges packets amongst Ethernet inter-
          faces.  The number b in the bind is optional and selects a
          particular bridge (default 0).

          The /net/bridge0 directory contains ctl, cache, log, and
          stats files, and numbered subdirectories for each physical
          interface.

          Opening the ctl file reserves an interface.  The file
          descriptor returned from the open(2) will point to the con-
          trol file, ctl, of the newly allocated interface.  Reading
          ctl returns a text string representing the number of the
          interface.  Writing ctl alters aspects of the interface.
          The possible ctl messages are:

          bind ether name ownhash path [pvid[#prio][,vlans...]]
               Treat the device mounted at path (e.g., `/net/ether0')
               as an Ethernet medium and associate it with this bridge
               (forward its packets to the other interfaces associated
               with this bridge).  Ownhash is an `owner hash'.  The
               optional [pvid[#prio][,vlans...]] argument is explained
               in vlan command below.

          bind tunnel name ownhash path path2 [pvid[#prio][,vlans...]]
               Treat the device mounted at path as a network tunnel
               carrying Ethernet packets, the device mounted at path2
               as an Ethernet and associate them with this bridge
               (forward its packets to the other interfaces associated
               with this bridge).  Read packets from the path inter-
               face and write them to the path2 interface.  Such tun-
               nels have an MTU of 1400 bytes.

          vlan pvid[#prio][,vlans...] type name [ownhash]
               Change the 802.1Q VLAN configuration of a port

     Page 1                       Plan 9            (printed 11/18/24)

     BRIDGE(3)                                               BRIDGE(3)

               identified by type, name and ownhash. The pvid is the
               "Native" VLAN id associated with untagged packets on a
               port.  Packets with a VLAN id of pvid will be send out
               untagged on the port.  Untagged packets received on the
               port will be tagged with the pvid. When pvid was not
               specified in a bind command above, ports default to a
               pvid of 1.  The pvid can be specified as 0 when
               untagged packets should be ignored on a port.  The
               optional prio argument specifies the default priority
               to assign to a incoming untagged packet on the port
               between 0 (lowest, default) and 7 (highest).  The
               vlans... argument specifies comma separated ranges of
               other VLAN id's that the port is a member of (for trunk
               ports).  Membership means the port is accepting tagged
               packets with VLAN id's listed here and ignores VLAN
               id's not listed here. Once accepted, packets are for-
               warded only to other ports that are members of the same
               (accepted) VLAN id.  Unless pvid is 0, a port is always
               a member of its own pvid VLAN id, so it does not need
               to be listed twice.

          unbind type name [ownhash]
               Disassociate the interface associated with name from
               this bridge.  Type must be `ether' or `tunnel'.

          cacheflush
               Clear the cache of (destination MAC address, VLAN id,
               port) tuples.

          delay delay0 delayn
               Set the delay0 and delayn parameters.  delay0 is the
               constant microsecond delay per packet and delayn is the
               microsecond delay per byte.

          set option
               Set bridge option. The only known option is `tcpmss',
               which limits the TCP Maximum Segment Size of TCP pack-
               ets passing through to 1300 bytes.

          clear option
               Clear bridge option.

          Reading stats returns statistics about the bridge.

          Reading the log file returns data from the bridge's log and
          will block at end of file awaiting new data.

          Reading the cache file prints the cache of (destination MAC
          address, VLAN id, port) tuples, one entry per line.  The
          format is: the destination MAC (e.g., Ethernet) address in
          hex, VLAN id, port number, count of packets from this
          address, count of packets to this address, expiry time in

     Page 2                       Plan 9            (printed 11/18/24)

     BRIDGE(3)                                               BRIDGE(3)

          seconds since the epoch, and `e' for expired entries or `v'
          for valid entries.

          In a connection subdirectory, ctl and local don't do any-
          thing, but status returns a one-line status summary.

     EXAMPLES
          Set up a network bridge between two Ethernets (`#l0' and
          `#l1').

               bind -a '#B' /net
               bind -a '#l1' /net
               echo 'bind ether outer 0 /net/ether0' >/net/bridge0/ctl
               echo 'bind ether inner 0 /net/ether1' >/net/bridge0/ctl

          Set up bridge1 with 3 access ports and a trunk port.

               # create bridge1
               bind -a '#B1' /net

               # nic for trunk carrying only tagged vlans 10,20 and 30
               bind -a '#l0' /net
               echo 'bind ether trunk 0 /net/ether0 0,10,20,30' >/net/bridge1/ctl

               # create virtual nics for access ports
               bind -a '#l1:sink ea=001122334401' /net
               bind -a '#l2:sink ea=001122334402' /net
               bind -a '#l3:sink ea=001122334403' /net
               echo 'bind ether port1 0 /net/ether1 10' >/net/bridge1/ctl
               echo 'bind ether port2 0 /net/ether2 20' >/net/bridge1/ctl
               echo 'bind ether port3 0 /net/ether3 30' >/net/bridge1/ctl

     SEE ALSO
          ip(3), ether(3)

     SOURCE
          /sys/src/9/port/devbridge.c

     Page 3                       Plan 9            (printed 11/18/24)