View | Details | Raw Unified | Return to bug 194000
Collapse All | Expand All

(-)./sys/net/if_bridgevar.h (-1 / +3 lines)
Lines 115-120 Link Here
115
#define	BRDGSPROTO		28	/* set protocol (ifbrparam) */
115
#define	BRDGSPROTO		28	/* set protocol (ifbrparam) */
116
#define	BRDGSTXHC		29	/* set tx hold count (ifbrparam) */
116
#define	BRDGSTXHC		29	/* set tx hold count (ifbrparam) */
117
#define	BRDGSIFAMAX		30	/* set max interface addrs (ifbreq) */
117
#define	BRDGSIFAMAX		30	/* set max interface addrs (ifbreq) */
118
#define	BRDGSIFGRPN		31	/* set bridge member group number */
118
119
119
/*
120
/*
120
 * Generic bridge control request.
121
 * Generic bridge control request.
Lines 132-138 Link Here
132
	uint32_t	ifbr_addrcnt;		/* member if addr number */
133
	uint32_t	ifbr_addrcnt;		/* member if addr number */
133
	uint32_t	ifbr_addrmax;		/* member if addr max */
134
	uint32_t	ifbr_addrmax;		/* member if addr max */
134
	uint32_t	ifbr_addrexceeded;	/* member if addr violations */
135
	uint32_t	ifbr_addrexceeded;	/* member if addr violations */
135
	uint8_t		pad[32];
136
	uint16_t	ifbr_groupnum;		/* member if group number */
137
	uint8_t		pad[30];
136
};
138
};
137
139
138
/* BRDGGIFFLAGS, BRDGSIFFLAGS */
140
/* BRDGGIFFLAGS, BRDGSIFFLAGS */
(-)./sys/net/if_bridge.c (-2 / +32 lines)
Lines 184-189 Link Here
184
	uint32_t		bif_addrmax;	/* max # of addresses */
184
	uint32_t		bif_addrmax;	/* max # of addresses */
185
	uint32_t		bif_addrcnt;	/* cur. # of addresses */
185
	uint32_t		bif_addrcnt;	/* cur. # of addresses */
186
	uint32_t		bif_addrexceeded;/* # of address violations */
186
	uint32_t		bif_addrexceeded;/* # of address violations */
187
	uint16_t		bif_groupnum;	/* group member number */
187
};
188
};
188
189
189
/*
190
/*
Lines 324-329 Link Here
324
static int	bridge_ioctl_gifsstp(struct bridge_softc *, void *);
325
static int	bridge_ioctl_gifsstp(struct bridge_softc *, void *);
325
static int	bridge_ioctl_sproto(struct bridge_softc *, void *);
326
static int	bridge_ioctl_sproto(struct bridge_softc *, void *);
326
static int	bridge_ioctl_stxhc(struct bridge_softc *, void *);
327
static int	bridge_ioctl_stxhc(struct bridge_softc *, void *);
328
static int	bridge_ioctl_sifgroupnum(struct bridge_softc *, void *);
329
327
static int	bridge_pfil(struct mbuf **, struct ifnet *, struct ifnet *,
330
static int	bridge_pfil(struct mbuf **, struct ifnet *, struct ifnet *,
328
		    int);
331
		    int);
329
static int	bridge_ip_checkbasic(struct mbuf **mp);
332
static int	bridge_ip_checkbasic(struct mbuf **mp);
Lines 482-487 Link Here
482
	{ bridge_ioctl_sifmaxaddr,	sizeof(struct ifbreq),
485
	{ bridge_ioctl_sifmaxaddr,	sizeof(struct ifbreq),
483
	  BC_F_COPYIN|BC_F_SUSER },
486
	  BC_F_COPYIN|BC_F_SUSER },
484
487
488
	{ bridge_ioctl_sifgroupnum,	sizeof(struct ifbreq),
489
	  BC_F_COPYIN|BC_F_SUSER },
490
485
};
491
};
486
const int bridge_control_table_size =
492
const int bridge_control_table_size =
487
    sizeof(bridge_control_table) / sizeof(bridge_control_table[0]);
493
    sizeof(bridge_control_table) / sizeof(bridge_control_table[0]);
Lines 1193-1198 Link Here
1193
	req->ifbr_priority = bp->bp_priority;
1199
	req->ifbr_priority = bp->bp_priority;
1194
	req->ifbr_path_cost = bp->bp_path_cost;
1200
	req->ifbr_path_cost = bp->bp_path_cost;
1195
	req->ifbr_portno = bif->bif_ifp->if_index & 0xfff;
1201
	req->ifbr_portno = bif->bif_ifp->if_index & 0xfff;
1202
	req->ifbr_groupnum = bif->bif_groupnum;
1196
	req->ifbr_proto = bp->bp_protover;
1203
	req->ifbr_proto = bp->bp_protover;
1197
	req->ifbr_role = bp->bp_role;
1204
	req->ifbr_role = bp->bp_role;
1198
	req->ifbr_stpflags = bp->bp_flags;
1205
	req->ifbr_stpflags = bp->bp_flags;
Lines 1327-1332 Link Here
1327
		strlcpy(breq.ifbr_ifsname, bif->bif_ifp->if_xname,
1334
		strlcpy(breq.ifbr_ifsname, bif->bif_ifp->if_xname,
1328
		    sizeof(breq.ifbr_ifsname));
1335
		    sizeof(breq.ifbr_ifsname));
1329
		breq.ifbr_ifsflags = bif->bif_flags;
1336
		breq.ifbr_ifsflags = bif->bif_flags;
1337
		breq.ifbr_groupnum = bif->bif_groupnum;
1330
		breq.ifbr_portno = bif->bif_ifp->if_index & 0xfff;
1338
		breq.ifbr_portno = bif->bif_ifp->if_index & 0xfff;
1331
		memcpy(buf, &breq, sizeof(breq));
1339
		memcpy(buf, &breq, sizeof(breq));
1332
		count++;
1340
		count++;
Lines 1546-1551 Link Here
1546
}
1554
}
1547
1555
1548
static int
1556
static int
1557
bridge_ioctl_sifgroupnum(struct bridge_softc *sc, void *arg)
1558
{
1559
	struct ifbreq *req = arg;
1560
	struct bridge_iflist *bif;
1561
1562
	bif = bridge_lookup_member(sc, req->ifbr_ifsname);
1563
	if (bif == NULL)
1564
		return (ENOENT);
1565
1566
	bif->bif_groupnum = req->ifbr_groupnum;
1567
	return 0;
1568
}
1569
1570
static int
1549
bridge_ioctl_sifmaxaddr(struct bridge_softc *sc, void *arg)
1571
bridge_ioctl_sifmaxaddr(struct bridge_softc *sc, void *arg)
1550
{
1572
{
1551
	struct ifbreq *req = arg;
1573
	struct ifbreq *req = arg;
Lines 2192-2198 Link Here
2192
2214
2193
	/* Private segments can not talk to each other */
2215
	/* Private segments can not talk to each other */
2194
	if (sbif->bif_flags & dbif->bif_flags & IFBIF_PRIVATE)
2216
	if (sbif->bif_flags & dbif->bif_flags & IFBIF_PRIVATE)
2195
		goto drop;
2217
	{
2218
		/* if the segment doesn't belong to a group, or the groups aren't the same */
2219
		if (sbif->bif_groupnum == 0 || dbif->bif_groupnum == 0 || (sbif->bif_groupnum != dbif->bif_groupnum))
2220
			goto drop;
2221
	}
2196
2222
2197
	if ((dbif->bif_flags & IFBIF_STP) &&
2223
	if ((dbif->bif_flags & IFBIF_STP) &&
2198
	    dbif->bif_stp.bp_state == BSTP_IFSTATE_DISCARDING)
2224
	    dbif->bif_stp.bp_state == BSTP_IFSTATE_DISCARDING)
Lines 2465-2471 Link Here
2465
2491
2466
		/* Private segments can not talk to each other */
2492
		/* Private segments can not talk to each other */
2467
		if (sbif && (sbif->bif_flags & dbif->bif_flags & IFBIF_PRIVATE))
2493
		if (sbif && (sbif->bif_flags & dbif->bif_flags & IFBIF_PRIVATE))
2468
			continue;
2494
		{
2495
			/* if the segment doesn't belong to a group, or the groups aren't the same */
2496
			if (sbif->bif_groupnum == 0 || dbif->bif_groupnum == 0 || (sbif->bif_groupnum != dbif->bif_groupnum))
2497
				continue;
2498
		}
2469
2499
2470
		if ((dbif->bif_flags & IFBIF_STP) &&
2500
		if ((dbif->bif_flags & IFBIF_STP) &&
2471
		    dbif->bif_stp.bp_state == BSTP_IFSTATE_DISCARDING)
2501
		    dbif->bif_stp.bp_state == BSTP_IFSTATE_DISCARDING)
(-)./sbin/ifconfig/ifbridge.c (+23 lines)
Lines 183-188 Link Here
183
		printf(" port %u priority %u", req->ifbr_portno,
183
		printf(" port %u priority %u", req->ifbr_portno,
184
		    req->ifbr_priority);
184
		    req->ifbr_priority);
185
		printf(" path cost %u", req->ifbr_path_cost);
185
		printf(" path cost %u", req->ifbr_path_cost);
186
		if(req->ifbr_ifsflags & IFBIF_PRIVATE)
187
			printf(" ifGroupNum %u", req->ifbr_groupnum);
186
188
187
		if (req->ifbr_ifsflags & IFBIF_STP) {
189
		if (req->ifbr_ifsflags & IFBIF_STP) {
188
			if (req->ifbr_proto <
190
			if (req->ifbr_proto <
Lines 653-658 Link Here
653
}
655
}
654
656
655
static void
657
static void
658
setbridge_ifgroupnum(const char *ifn, const char *group, int s,
659
    const struct afswtch *afp)
660
{
661
	struct ifbreq req;
662
	u_long val;
663
664
	memset(&req, 0, sizeof(req));
665
666
	if (get_val(group, &val) < 0 || (val & ~0xffff) != 0)
667
		errx(1, "invalid value: %s",  group);
668
669
	strlcpy(req.ifbr_ifsname, ifn, sizeof(req.ifbr_ifsname));
670
	req.ifbr_groupnum = (val & 0xffff);
671
672
	if (do_cmd(s, BRDGSIFGRPN, &req, sizeof(req), 1) < 0)
673
		err(1, "BRDGSIFGRPN %s",  group);
674
}
675
676
static void
656
setbridge_ifmaxaddr(const char *ifn, const char *arg, int s,
677
setbridge_ifmaxaddr(const char *ifn, const char *arg, int s,
657
    const struct afswtch *afp)
678
    const struct afswtch *afp)
658
{
679
{
Lines 698-703 Link Here
698
{
719
{
699
720
700
	do_bridgeflag(s, val, IFBIF_PRIVATE, 0);
721
	do_bridgeflag(s, val, IFBIF_PRIVATE, 0);
722
	setbridge_ifgroupnum(val, "0", s, afp);
701
}
723
}
702
724
703
static struct cmd bridge_cmds[] = {
725
static struct cmd bridge_cmds[] = {
Lines 739-744 Link Here
739
	DEF_CMD_ARG("timeout",		setbridge_timeout),
761
	DEF_CMD_ARG("timeout",		setbridge_timeout),
740
	DEF_CMD_ARG("private",		setbridge_private),
762
	DEF_CMD_ARG("private",		setbridge_private),
741
	DEF_CMD_ARG("-private",		unsetbridge_private),
763
	DEF_CMD_ARG("-private",		unsetbridge_private),
764
	DEF_CMD_ARG2("ifgroupnum",	setbridge_ifgroupnum),
742
};
765
};
743
static struct afswtch af_bridge = {
766
static struct afswtch af_bridge = {
744
	.af_name	= "af_bridge",
767
	.af_name	= "af_bridge",
(-)./sbin/ifconfig/ifconfig.8 (+6 lines)
Lines 2229-2234 Link Here
2229
Clear the
2229
Clear the
2230
.Dq private
2230
.Dq private
2231
attribute on a member interface.
2231
attribute on a member interface.
2232
.It Cm ifgroupnum Ar interface Ar groupNum
2233
Allow spans marked as
2234
.Dq private
2235
with the same
2236
.Dq groupNum
2237
to forward traffic amongst each other.
2232
.It Cm span Ar interface
2238
.It Cm span Ar interface
2233
Add the interface named by
2239
Add the interface named by
2234
.Ar interface
2240
.Ar interface
(-)/etc/rc.d/bridge (+23 lines)
Lines 44-49 Link Here
44
	esac
44
	esac
45
}
45
}
46
46
47
bridge_add_if_params() {
48
	bridge=$1
49
	iface=$2
50
51
	eval params=\$${bridge}_${iface}
52
	if [ -n "${params}" ]; then
53
		for param in ${params}; do
54
			# morph "x=n" into "x iface n" so that two argument cmds work
55
			paramalt="`echo $param | sed -e\"s/=\(.*\)/ ${iface} \1/\"`"
56
			if [ "$param" != "$paramalt" ]; then
57
				ifconfig $bridge $paramalt > /dev/null 2>&1
58
			else
59
				ifconfig $bridge $param $iface > /dev/null 2>&1
60
			fi
61
		done
62
	fi
63
}
64
47
bridge_test() {
65
bridge_test() {
48
	bridge=$1
66
	bridge=$1
49
	iface=$2
67
	iface=$2
Lines 53-58 Link Here
53
		for i in ${interfaces}; do
71
		for i in ${interfaces}; do
54
			if glob_int $iface $i ; then
72
			if glob_int $iface $i ; then
55
				ifconfig $bridge $cmd $iface > /dev/null 2>&1
73
				ifconfig $bridge $cmd $iface > /dev/null 2>&1
74
75
				# apply additional bridge parameters for the interface ?
76
				if [ "$cmd" = "addm" ]; then
77
					bridge_add_if_params $bridge $iface
78
				fi
56
				return
79
				return
57
			fi
80
			fi
58
		done
81
		done

Return to bug 194000