Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 24 Jan 2005 08:32:12 +0500
From:      Boris Kovalenko <boris@ntmk.ru>
To:        Brooks Davis <brooks@one-eyed-alien.net>, freebsd-net@freebsd.org
Subject:   Re: [PATCH] 802.1p priority (fixed)
Message-ID:  <41F46C3C.20205@ntmk.ru>
In-Reply-To: <20050123193711.GB29225@odin.ac.hmc.edu>
References:  <41F33E9F.9090301@tagnet.ru> <20050123193711.GB29225@odin.ac.hmc.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------010401000303000403050708
Content-Type: text/plain; charset=KOI8-R; format=flowed
Content-Transfer-Encoding: 7bit

Brooks Davis wrote:
Hello!

> 
> 
> I still don't see how this usefull differs from taking action or not
> taking action.
Just more simple to understand (trusted or not trusted vlan (IMHO)), but 
taking action via IPFW of course will be more flexible.
> 
> What Cisco does is of rather limited relevence IMO.  The default case of
> a FreeBSD system is not a bridge or router but a host.  We need to
> determine what makes sense for both the bridge/router case and the host
> case.  Cisco's are for all practical purposes, not hosts.
Thinking my idea satisfies router/bridge an host as well. We may set 
value or may pass-trough it.
> I've found at least one refrence when googling for 802.1p which says
> that vlan 0 is reserved and means that the tag is only a priority.  In
> that case there is no vlan and I don't think vlan devices should be
> involved.  If they are, you must set the priority on every frame or
> priority and non-priority frames will be delivered to different
> intefaces which may or may not be what you want.
> 
> I'm not 100% sure that's correct, but the IEEE has made it practialy
> impossiable to find 802.1p.  I haven't found it yet.
Augh... it that case. Yes, VLID==0 is reserved for "priority" packets, 
but it should not be used in usual way. And this packet will have full 
802.1Q header indeed.
>>
>>	And what this changes? Some switches totally ignore 802.1p. We're 
>>talking about IEEE standard and should fully support it. Also, may You 
>>point me where You have read this?
> 
> 
> The issue is that you may need the ability to treat some values as
> though they are the same because some network environments will do this.
Don't think that. What to do with each value is our own decision and 
only when we want to implement priority queues, in all other cases we 
may just ignore it (this way FreeBSD currently does).
> 
> While I think a lower level solution will be the most useful in the
> end, I don't object to an interface based solution.  I think you should
> proceed with that with the idea that you add a third, optional keyword
> to vlan initalization to specify priority.  That way you can create
> seperate interfaces for each priority for any vlan tag.  Something like:
> 
> ifconfig vlan create vlan 2 vlandev fxp0 vlanpri 3
But this is already done with my patch!!! :))) Have You seen it? I've 
added also ability to set apropriate CFI. Attached patch again to this 
message. Please review it again :)
> 
> -- Brooks
> 


-- 
With respect,
	Boris

--------------010401000303000403050708
Content-Type: text/plain;
 name="patch-8021p.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="patch-8021p.diff"

--- sbin/ifconfig/ifconfig.h.orig	Wed Jan 19 10:44:20 2005
+++ sbin/ifconfig/ifconfig.h	Fri Jan 21 09:11:22 2005
@@ -49,6 +49,8 @@
 
 extern void setvlantag(const char *, int, int, const struct afswtch *rafp);
 extern void setvlandev(const char *, int, int, const struct afswtch *rafp);
+extern void setvlanpri(const char *, int, int, const struct afswtch *rafp);
+extern void setvlancfi(const char *, int, int, const struct afswtch *rafp);
 extern void unsetvlandev(const char *, int, int, const struct afswtch *rafp);
 extern void vlan_status(int s, struct rt_addrinfo *);
 
--- sbin/ifconfig/ifconfig.c.orig	Wed Jan 19 10:56:44 2005
+++ sbin/ifconfig/ifconfig.c	Fri Jan 21 09:11:54 2005
@@ -247,6 +247,8 @@
 #endif
 #ifdef USE_VLANS
 	{ "vlan",	NEXTARG,	setvlantag },
+	{ "vlanpri",	NEXTARG,	setvlanpri },
+	{ "vlancfi",	NEXTARG,	setvlancfi },
 	{ "vlandev",	NEXTARG,	setvlandev },
 	{ "-vlandev",	NEXTARG,	unsetvlandev },
 #endif
--- sbin/ifconfig/ifvlan.c.orig	Thu Apr 18 23:14:09 2002
+++ sbin/ifconfig/ifvlan.c	Fri Jan 21 12:19:38 2005
@@ -59,6 +59,8 @@
   "$FreeBSD: src/sbin/ifconfig/ifvlan.c,v 1.5 2002/04/18 17:14:09 imp Exp $";
 #endif
 static int			__tag = 0;
+static int			__pri = 0;
+static int			__cfi = 0;
 static int			__have_tag = 0;
 
 void
@@ -72,9 +74,10 @@
 	if (ioctl(s, SIOCGETVLAN, (caddr_t)&ifr) == -1)
 		return;
 
-	printf("\tvlan: %d parent interface: %s\n",
-	    vreq.vlr_tag, vreq.vlr_parent[0] == '\0' ?
-	    "<none>" : vreq.vlr_parent);
+	printf("\tvlan: %d 802.1p: %d CFI: %d parent interface: %s \n",
+	    EVL_VLANOFTAG(vreq.vlr_tag), EVL_PRIOFTAG(vreq.vlr_tag),
+	    EVL_CFIOFTAG(vreq.vlr_tag),
+	    vreq.vlr_parent[0] == '\0' ? "<none>" : vreq.vlr_parent );
 
 	return;
 }
@@ -88,13 +91,66 @@
 	__tag = tag = atoi(val);
 	__have_tag = 1;
 
+	if(tag < 1 || tag > 4094)
+	    errx(1, "VLAN ID shoud be in range 1..4094");
+
+	bzero((char *)&vreq, sizeof(struct vlanreq));
+	ifr.ifr_data = (caddr_t)&vreq;
+
+	if (ioctl(s, SIOCGETVLAN, (caddr_t)&ifr) == -1)
+		err(1, "SIOCGETVLAN");
+
+	vreq.vlr_tag = EVL_MAKETAG(tag, __pri, __cfi);
+
+	if (ioctl(s, SIOCSETVLAN, (caddr_t)&ifr) == -1)
+		err(1, "SIOCSETVLAN");
+
+	return;
+}
+
+void
+setvlanpri(const char *val, int d, int s, const struct afswtch	*afp)
+{
+	u_int16_t		pri;
+	struct vlanreq		vreq;
+
+	__pri = pri = atoi(val);
+
+	if(pri > 7)
+	    errx(1, "VLAN 802.1p shoud be in range 0..7");
+
+	bzero((char *)&vreq, sizeof(struct vlanreq));
+	ifr.ifr_data = (caddr_t)&vreq;
+
+	if (ioctl(s, SIOCGETVLAN, (caddr_t)&ifr) == -1)
+		err(1, "SIOCGETVLAN");
+
+	vreq.vlr_tag = EVL_MAKETAG(EVL_VLANOFTAG(vreq.vlr_tag), pri, __cfi);
+
+	if (ioctl(s, SIOCSETVLAN, (caddr_t)&ifr) == -1)
+		err(1, "SIOCSETVLAN");
+
+	return;
+}
+
+void
+setvlancfi(const char *val, int d, int s, const struct afswtch	*afp)
+{
+	u_int16_t		cfi;
+	struct vlanreq		vreq;
+
+	__cfi = cfi = atoi(val);
+
+	if(cfi > 1)
+	    errx(1, "VLAN CFI shoud be 0 or 1");
+
 	bzero((char *)&vreq, sizeof(struct vlanreq));
 	ifr.ifr_data = (caddr_t)&vreq;
 
 	if (ioctl(s, SIOCGETVLAN, (caddr_t)&ifr) == -1)
 		err(1, "SIOCGETVLAN");
 
-	vreq.vlr_tag = tag;
+	vreq.vlr_tag = EVL_MAKETAG(EVL_VLANOFTAG(vreq.vlr_tag), __pri, cfi);
 
 	if (ioctl(s, SIOCSETVLAN, (caddr_t)&ifr) == -1)
 		err(1, "SIOCSETVLAN");
@@ -117,7 +173,7 @@
 		err(1, "SIOCGETVLAN");
 
 	strncpy(vreq.vlr_parent, val, sizeof(vreq.vlr_parent));
-	vreq.vlr_tag = __tag;
+	vreq.vlr_tag = EVL_MAKETAG(__tag, __pri, __cfi);
 
 	if (ioctl(s, SIOCSETVLAN, (caddr_t)&ifr) == -1)
 		err(1, "SIOCSETVLAN");
--- sbin/ifconfig/ifconfig.8.orig	Thu Sep 30 20:25:39 2004
+++ sbin/ifconfig/ifconfig.8	Fri Jan 21 09:39:24 2005
@@ -386,15 +386,35 @@
 pseudo interface, set the VLAN tag value
 to
 .Ar vlan_tag .
-This value is a 16-bit number which is used to create an 802.1Q
+This value is a 12-bit number which is used to create an 802.1Q
 VLAN header for packets sent from the
 .Xr vlan 4
 interface.
 Note that
-.Cm vlan
+.Cm vlan, vlanpri, vlancfi
 and
 .Cm vlandev
-must both be set at the same time.
+must be set at the same time.
+.It Cm vlanpri Ar vlan_pri
+If the interface is a
+.Xr vlan 4
+pseudo interface, set the 802.1p priority value
+to
+.Ar vlan_pri .
+This value is a 3-bit number which is used to tag outgoing
+VLAN packtes with apropriate priority. If
+.Cm vlanpri
+is omitted it default to 0.
+.It Cm vlancfi Ar vlan_cfi
+If the interface is a
+.Xr vlan 4
+pseudo interface, set the CFI value
+to
+.Ar vlan_cfi .
+This value is a 1-bit number which is used to tag outgoing
+VLAN packtes with apropriate CFI value. If
+.Cm vlancfi
+is omitted it default to 0.
 .It Cm vlandev Ar iface
 If the interface is a
 .Xr vlan 4
--- sys/net/if_vlan_var.h.orig	Mon Jan 19 00:29:04 2004
+++ sys/net/if_vlan_var.h	Fri Jan 21 09:46:46 2005
@@ -43,6 +43,8 @@
 #define EVL_VLID_MASK	0x0FFF
 #define	EVL_VLANOFTAG(tag) ((tag) & EVL_VLID_MASK)
 #define	EVL_PRIOFTAG(tag) (((tag) >> 13) & 7)
+#define	EVL_CFIOFTAG(tag) (((tag) >> 12) & 1)
+#define	EVL_MAKETAG(vlid,pri,cfi) ((((((pri) & 7) << 1) | ((cfi) & 1)) << 12) | ((vlid) & EVL_VLID_MASK))
 
 /* sysctl(3) tags, for compatibility purposes */
 #define	VLANCTL_PROTO	1
@@ -52,8 +54,8 @@
  * Configuration structure for SIOCSETVLAN and SIOCGETVLAN ioctls.
  */
 struct	vlanreq {
-	char	vlr_parent[IFNAMSIZ];
-	u_short	vlr_tag;
+	char		vlr_parent[IFNAMSIZ];
+	u_int16_t	vlr_tag;
 };
 #define	SIOCSETVLAN	SIOCSIFGENERIC
 #define	SIOCGETVLAN	SIOCGIFGENERIC
--- sys/net/if_vlan.c.orig	Wed Jan 19 10:40:32 2005
+++ sys/net/if_vlan.c	Fri Jan 21 09:05:45 2005
@@ -930,15 +930,6 @@
 			error = ENOENT;
 			break;
 		}
-		/*
-		 * Don't let the caller set up a VLAN tag with
-		 * anything except VLID bits.
-		 */
-
-		if (vlr.vlr_tag & ~EVL_VLID_MASK) {
-			error = EINVAL;
-			break;
-		}
 
 		VLAN_LOCK();
 		error = vlan_config(ifv, p);

--------------010401000303000403050708--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?41F46C3C.20205>