FreeBSD Bugzilla – Attachment 147763 Details for
Bug 194000
Enhance if_bridge to forward pkts between spans marked private with the same group number
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch to add ifgroupnum to private bridge member
ifconfig_bridge_groupnum.diff (text/plain), 6.59 KB, created by
neal
on 2014-09-28 17:32:35 UTC
(
hide
)
Description:
Patch to add ifgroupnum to private bridge member
Filename:
MIME Type:
Creator:
neal
Created:
2014-09-28 17:32:35 UTC
Size:
6.59 KB
patch
obsolete
>--- i386/10.0-RELEASE/sys/net/if_bridgevar.h 2014-01-16 17:53:02.000000000 -0600 >+++ ./sys/net/if_bridgevar.h 2014-09-27 22:32:59.000000000 -0500 >@@ -115,6 +115,7 @@ > #define BRDGSPROTO 28 /* set protocol (ifbrparam) */ > #define BRDGSTXHC 29 /* set tx hold count (ifbrparam) */ > #define BRDGSIFAMAX 30 /* set max interface addrs (ifbreq) */ >+#define BRDGSIFGRPN 31 /* set bridge member group number */ > > /* > * Generic bridge control request. >@@ -132,7 +133,8 @@ > uint32_t ifbr_addrcnt; /* member if addr number */ > uint32_t ifbr_addrmax; /* member if addr max */ > uint32_t ifbr_addrexceeded; /* member if addr violations */ >- uint8_t pad[32]; >+ uint16_t ifbr_groupnum; /* member if group number */ >+ uint8_t pad[30]; > }; > > /* BRDGGIFFLAGS, BRDGSIFFLAGS */ >--- i386/10.0-RELEASE/sys/net/if_bridge.c 2014-01-16 17:53:02.000000000 -0600 >+++ ./sys/net/if_bridge.c 2014-09-27 22:32:00.000000000 -0500 >@@ -184,6 +184,7 @@ > uint32_t bif_addrmax; /* max # of addresses */ > uint32_t bif_addrcnt; /* cur. # of addresses */ > uint32_t bif_addrexceeded;/* # of address violations */ >+ uint16_t bif_groupnum; /* group member number */ > }; > > /* >@@ -324,6 +325,8 @@ > static int bridge_ioctl_gifsstp(struct bridge_softc *, void *); > static int bridge_ioctl_sproto(struct bridge_softc *, void *); > static int bridge_ioctl_stxhc(struct bridge_softc *, void *); >+static int bridge_ioctl_sifgroupnum(struct bridge_softc *, void *); >+ > static int bridge_pfil(struct mbuf **, struct ifnet *, struct ifnet *, > int); > static int bridge_ip_checkbasic(struct mbuf **mp); >@@ -482,6 +485,9 @@ > { bridge_ioctl_sifmaxaddr, sizeof(struct ifbreq), > BC_F_COPYIN|BC_F_SUSER }, > >+ { bridge_ioctl_sifgroupnum, sizeof(struct ifbreq), >+ BC_F_COPYIN|BC_F_SUSER }, >+ > }; > const int bridge_control_table_size = > sizeof(bridge_control_table) / sizeof(bridge_control_table[0]); >@@ -1193,6 +1199,7 @@ > req->ifbr_priority = bp->bp_priority; > req->ifbr_path_cost = bp->bp_path_cost; > req->ifbr_portno = bif->bif_ifp->if_index & 0xfff; >+ req->ifbr_groupnum = bif->bif_groupnum; > req->ifbr_proto = bp->bp_protover; > req->ifbr_role = bp->bp_role; > req->ifbr_stpflags = bp->bp_flags; >@@ -1327,6 +1334,7 @@ > strlcpy(breq.ifbr_ifsname, bif->bif_ifp->if_xname, > sizeof(breq.ifbr_ifsname)); > breq.ifbr_ifsflags = bif->bif_flags; >+ breq.ifbr_groupnum = bif->bif_groupnum; > breq.ifbr_portno = bif->bif_ifp->if_index & 0xfff; > memcpy(buf, &breq, sizeof(breq)); > count++; >@@ -1546,6 +1554,20 @@ > } > > static int >+bridge_ioctl_sifgroupnum(struct bridge_softc *sc, void *arg) >+{ >+ struct ifbreq *req = arg; >+ struct bridge_iflist *bif; >+ >+ bif = bridge_lookup_member(sc, req->ifbr_ifsname); >+ if (bif == NULL) >+ return (ENOENT); >+ >+ bif->bif_groupnum = req->ifbr_groupnum; >+ return 0; >+} >+ >+static int > bridge_ioctl_sifmaxaddr(struct bridge_softc *sc, void *arg) > { > struct ifbreq *req = arg; >@@ -2192,7 +2214,11 @@ > > /* Private segments can not talk to each other */ > if (sbif->bif_flags & dbif->bif_flags & IFBIF_PRIVATE) >- goto drop; >+ { >+ /* if the segment doesn't belong to a group, or the groups aren't the same */ >+ if (sbif->bif_groupnum == 0 || dbif->bif_groupnum == 0 || (sbif->bif_groupnum != dbif->bif_groupnum)) >+ goto drop; >+ } > > if ((dbif->bif_flags & IFBIF_STP) && > dbif->bif_stp.bp_state == BSTP_IFSTATE_DISCARDING) >@@ -2465,7 +2491,11 @@ > > /* Private segments can not talk to each other */ > if (sbif && (sbif->bif_flags & dbif->bif_flags & IFBIF_PRIVATE)) >- continue; >+ { >+ /* if the segment doesn't belong to a group, or the groups aren't the same */ >+ if (sbif->bif_groupnum == 0 || dbif->bif_groupnum == 0 || (sbif->bif_groupnum != dbif->bif_groupnum)) >+ continue; >+ } > > if ((dbif->bif_flags & IFBIF_STP) && > dbif->bif_stp.bp_state == BSTP_IFSTATE_DISCARDING) >--- i386/10.0-RELEASE/sbin/ifconfig/ifbridge.c 2014-01-16 17:55:20.000000000 -0600 >+++ ./sbin/ifconfig/ifbridge.c 2014-09-27 22:32:14.000000000 -0500 >@@ -183,6 +183,8 @@ > printf(" port %u priority %u", req->ifbr_portno, > req->ifbr_priority); > printf(" path cost %u", req->ifbr_path_cost); >+ if(req->ifbr_ifsflags & IFBIF_PRIVATE) >+ printf(" ifGroupNum %u", req->ifbr_groupnum); > > if (req->ifbr_ifsflags & IFBIF_STP) { > if (req->ifbr_proto < >@@ -653,6 +655,25 @@ > } > > static void >+setbridge_ifgroupnum(const char *ifn, const char *group, int s, >+ const struct afswtch *afp) >+{ >+ struct ifbreq req; >+ u_long val; >+ >+ memset(&req, 0, sizeof(req)); >+ >+ if (get_val(group, &val) < 0 || (val & ~0xffff) != 0) >+ errx(1, "invalid value: %s", group); >+ >+ strlcpy(req.ifbr_ifsname, ifn, sizeof(req.ifbr_ifsname)); >+ req.ifbr_groupnum = (val & 0xffff); >+ >+ if (do_cmd(s, BRDGSIFGRPN, &req, sizeof(req), 1) < 0) >+ err(1, "BRDGSIFGRPN %s", group); >+} >+ >+static void > setbridge_ifmaxaddr(const char *ifn, const char *arg, int s, > const struct afswtch *afp) > { >@@ -698,6 +719,7 @@ > { > > do_bridgeflag(s, val, IFBIF_PRIVATE, 0); >+ setbridge_ifgroupnum(val, "0", s, afp); > } > > static struct cmd bridge_cmds[] = { >@@ -739,6 +761,7 @@ > DEF_CMD_ARG("timeout", setbridge_timeout), > DEF_CMD_ARG("private", setbridge_private), > DEF_CMD_ARG("-private", unsetbridge_private), >+ DEF_CMD_ARG2("ifgroupnum", setbridge_ifgroupnum), > }; > static struct afswtch af_bridge = { > .af_name = "af_bridge", >--- i386/10.0-RELEASE/sbin/ifconfig/ifconfig.8 2014-01-16 17:55:20.000000000 -0600 >+++ ./sbin/ifconfig/ifconfig.8 2014-09-27 22:02:31.000000000 -0500 >@@ -2229,6 +2229,12 @@ > Clear the > .Dq private > attribute on a member interface. >+.It Cm ifgroupnum Ar interface Ar groupNum >+Allow spans marked as >+.Dq private >+with the same >+.Dq groupNum >+to forward traffic amongst each other. > .It Cm span Ar interface > Add the interface named by > .Ar interface >--- i386/10.0-RELEASE/etc/rc.d/bridge 2014-01-16 18:03:20.000000000 -0600 >+++ /etc/rc.d/bridge 2014-09-27 19:07:25.000000000 -0500 >@@ -44,6 +44,24 @@ > esac > } > >+bridge_add_if_params() { >+ bridge=$1 >+ iface=$2 >+ >+ eval params=\$${bridge}_${iface} >+ if [ -n "${params}" ]; then >+ for param in ${params}; do >+ # morph "x=n" into "x iface n" so that two argument cmds work >+ paramalt="`echo $param | sed -e\"s/=\(.*\)/ ${iface} \1/\"`" >+ if [ "$param" != "$paramalt" ]; then >+ ifconfig $bridge $paramalt > /dev/null 2>&1 >+ else >+ ifconfig $bridge $param $iface > /dev/null 2>&1 >+ fi >+ done >+ fi >+} >+ > bridge_test() { > bridge=$1 > iface=$2 >@@ -53,6 +71,11 @@ > for i in ${interfaces}; do > if glob_int $iface $i ; then > ifconfig $bridge $cmd $iface > /dev/null 2>&1 >+ >+ # apply additional bridge parameters for the interface ? >+ if [ "$cmd" = "addm" ]; then >+ bridge_add_if_params $bridge $iface >+ fi > return > fi > done
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 194000
: 147763