Date: Wed, 19 Jan 2005 14:19:33 +0500 From: Boris Kovalenko <boris@ntmk.ru> To: freebsd-current@freebsd.org Subject: [PATCH] 802.1p priority Message-ID: <41EE2625.4090609@ntmk.ru>
next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------060408090903080102040103
Content-Type: text/plain; charset=KOI8-R; format=flowed
Content-Transfer-Encoding: 7bit
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
--------------060408090903080102040103
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 Wed Jan 19 10:09:57 2005
@@ -49,6 +49,7 @@
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
@@ -59,6 +59,7 @@
"$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
@@ -72,9 +73,9 @@
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;
}
@@ -94,7 +95,29 @@
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");
@@ -117,7 +140,7 @@
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
@@ -43,6 +43,7 @@
#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
@@ -52,8 +53,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 Wed Jan 19 10:42:22 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);
--- sbin/ifconfig/ifconfig.c.orig Wed Jan 19 10:56:44 2005
+++ sbin/ifconfig/ifconfig.c Wed Jan 19 10:56:24 2005
@@ -248,6 +248,7 @@
#ifdef USE_VLANS
{ "vlan", NEXTARG, setvlantag },
{ "vlandev", NEXTARG, setvlandev },
+ { "vlanpri", NEXTARG, setvlandev },
{ "-vlandev", NEXTARG, unsetvlandev },
#endif
#if 0
--------------060408090903080102040103--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?41EE2625.4090609>
