[PATCH] 802.1p priority

From: Boris Kovalenko <boris_at_ntmk.ru>
Date: Wed, 19 Jan 2005 14:19:33 +0500
Hello!

	I want to implement 802.1p priority tagging for VLAN. I made this dirty 
patch and wonder - it works for me. May somebody look at it and tell me 
is this enough for BSD community or should I look and patch something more?

-- 
With respect,
	Boris

--- sbin/ifconfig/ifconfig.h.orig	Wed Jan 19 10:44:20 2005
+++ sbin/ifconfig/ifconfig.h	Wed Jan 19 10:09:57 2005
_at__at_ -49,6 +49,7 _at__at_
 
 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 unsetvlandev(const char *, int, int, const struct afswtch *rafp);
 extern void vlan_status(int s, struct rt_addrinfo *);
 
--- sbin/ifconfig/ifvlan.c.orig	Thu Apr 18 23:14:09 2002
+++ sbin/ifconfig/ifvlan.c	Wed Jan 19 10:46:52 2005
_at__at_ -59,6 +59,7 _at__at_
   "$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			__have_tag = 0;
 
 void
_at__at_ -72,9 +73,9 _at__at_
 	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 parent interface: %s 802.1p: %d\n",
+	    EVL_VLANOFTAG(vreq.vlr_tag), vreq.vlr_parent[0] == '\0' ?
+	    "<none>" : vreq.vlr_parent, EVL_PRIOFTAG(vreq.vlr_tag));
 
 	return;
 }
_at__at_ -94,7 +95,29 _at__at_
 	if (ioctl(s, SIOCGETVLAN, (caddr_t)&ifr) == -1)
 		err(1, "SIOCGETVLAN");
 
-	vreq.vlr_tag = tag;
+	vreq.vlr_tag = EVL_MAKETAG(tag, __pri);
+
+	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);
+
+	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);
 
 	if (ioctl(s, SIOCSETVLAN, (caddr_t)&ifr) == -1)
 		err(1, "SIOCSETVLAN");
_at__at_ -117,7 +140,7 _at__at_
 		err(1, "SIOCGETVLAN");
 
 	strncpy(vreq.vlr_parent, val, sizeof(vreq.vlr_parent));
-	vreq.vlr_tag = __tag;
+	vreq.vlr_tag = EVL_MAKETAG(__tag, __pri);
 
 	if (ioctl(s, SIOCSETVLAN, (caddr_t)&ifr) == -1)
 		err(1, "SIOCSETVLAN");
--- sys/net/if_vlan_var.h.orig	Mon Jan 19 00:29:04 2004
+++ sys/net/if_vlan_var.h	Wed Jan 19 10:42:04 2005
_at__at_ -43,6 +43,7 _at__at_
 #define EVL_VLID_MASK	0x0FFF
 #define	EVL_VLANOFTAG(tag) ((tag) & EVL_VLID_MASK)
 #define	EVL_PRIOFTAG(tag) (((tag) >> 13) & 7)
+#define EVL_MAKETAG(tag,pri) ((((pri) & 7) << 13) | ((tag) & EVL_VLID_MASK))
 
 /* sysctl(3) tags, for compatibility purposes */
 #define	VLANCTL_PROTO	1
_at__at_ -52,8 +53,8 _at__at_
  * 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	Wed Jan 19 10:42:22 2005
_at__at_ -930,15 +930,6 _at__at_
 			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);
--- sbin/ifconfig/ifconfig.c.orig	Wed Jan 19 10:56:44 2005
+++ sbin/ifconfig/ifconfig.c	Wed Jan 19 10:56:24 2005
_at__at_ -248,6 +248,7 _at__at_
 #ifdef USE_VLANS
 	{ "vlan",	NEXTARG,	setvlantag },
 	{ "vlandev",	NEXTARG,	setvlandev },
+	{ "vlanpri",	NEXTARG,	setvlandev },
 	{ "-vlandev",	NEXTARG,	unsetvlandev },
 #endif
 #if 0
Received on Wed Jan 19 2005 - 08:19:37 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:26 UTC