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

next in thread | previous in thread | raw e-mail | index | archive | help

--J2SCkAp4GZ/dPZZf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Mon, Jan 24, 2005 at 08:32:12AM +0500, Boris Kovalenko wrote:
> Brooks Davis wrote:
> Hello!
>=20
> >
> >
> >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=
=20
> taking action via IPFW of course will be more flexible.

I disagree it's more simple.

> >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=20
> added also ability to set apropriate CFI. Attached patch again to this=20
> message. Please review it again :)

I missread your patch before.  Sorry about that.  Overall, this seems
like a step forward.  I would like this interface to be labled as
subject to change in the ifconfig manpage so that a solution that does
not treat different priorities as seperate interfaces is not precluded
by this specific implementation.  I'm sure we can keep an interface that
handles priorities as seperate interfaces, but I'm not sure we'll want
to do it via the vlan device (attractivly simple though that is.)

This patch appears to be against 4 or 5.  In 6 we've largly rewritten
ifconfig so the patch won't apply.  It looks like a simple matter to fix
this issue.  We'll need to commit to 6 before 4 or 5.

I've embeded some comments in the text below.

-- Brooks

> --- 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 @@
> =20
>  extern void setvlantag(const char *, int, int, const struct afswtch *raf=
p);
>  extern void setvlandev(const char *, int, int, const struct afswtch *raf=
p);
> +extern void setvlanpri(const char *, int, int, const struct afswtch *raf=
p);
> +extern void setvlancfi(const char *, int, int, const struct afswtch *raf=
p);
>  extern void unsetvlandev(const char *, int, int, const struct afswtch *r=
afp);
>  extern void vlan_status(int s, struct rt_addrinfo *);
> =20
> --- 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 Ex=
p $";
>  #endif
>  static int			__tag =3D 0;
> +static int			__pri =3D 0;
> +static int			__cfi =3D 0;
>  static int			__have_tag =3D 0;
> =20
>  void
> @@ -72,9 +74,10 @@
>  	if (ioctl(s, SIOCGETVLAN, (caddr_t)&ifr) =3D=3D -1)
>  		return;
> =20
> -	printf("\tvlan: %d parent interface: %s\n",
> -	    vreq.vlr_tag, vreq.vlr_parent[0] =3D=3D '\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] =3D=3D '\0' ? "<none>" : vreq.vlr_parent );
> =20
>  	return;
>  }
> @@ -88,13 +91,66 @@
>  	__tag =3D tag =3D atoi(val);
>  	__have_tag =3D 1;
> =20
> +	if(tag < 1 || tag > 4094)
> +	    errx(1, "VLAN ID shoud be in range 1..4094");

errx should be fully indented.

> +
> +	bzero((char *)&vreq, sizeof(struct vlanreq));
> +	ifr.ifr_data =3D (caddr_t)&vreq;
> +
> +	if (ioctl(s, SIOCGETVLAN, (caddr_t)&ifr) =3D=3D -1)
> +		err(1, "SIOCGETVLAN");
> +
> +	vreq.vlr_tag =3D EVL_MAKETAG(tag, __pri, __cfi);
> +
> +	if (ioctl(s, SIOCSETVLAN, (caddr_t)&ifr) =3D=3D -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 =3D pri =3D atoi(val);

I know other nearby code does this, but atoi should not be used.  It has
not useful error checking.  strtoul should be used instead.

> +
> +	if(pri > 7)
> +	    errx(1, "VLAN 802.1p shoud be in range 0..7");

errx should be fully indented.

> +
> +	bzero((char *)&vreq, sizeof(struct vlanreq));
> +	ifr.ifr_data =3D (caddr_t)&vreq;
> +
> +	if (ioctl(s, SIOCGETVLAN, (caddr_t)&ifr) =3D=3D -1)
> +		err(1, "SIOCGETVLAN");
> +
> +	vreq.vlr_tag =3D EVL_MAKETAG(EVL_VLANOFTAG(vreq.vlr_tag), pri, __cfi);
> +
> +	if (ioctl(s, SIOCSETVLAN, (caddr_t)&ifr) =3D=3D -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 =3D cfi =3D atoi(val);

strtoul

> +
> +	if(cfi > 1)
> +	    errx(1, "VLAN CFI shoud be 0 or 1");

indent.

> +
>  	bzero((char *)&vreq, sizeof(struct vlanreq));
>  	ifr.ifr_data =3D (caddr_t)&vreq;
> =20
>  	if (ioctl(s, SIOCGETVLAN, (caddr_t)&ifr) =3D=3D -1)
>  		err(1, "SIOCGETVLAN");
> =20
> -	vreq.vlr_tag =3D tag;
> +	vreq.vlr_tag =3D EVL_MAKETAG(EVL_VLANOFTAG(vreq.vlr_tag), __pri, cfi);
> =20
>  	if (ioctl(s, SIOCSETVLAN, (caddr_t)&ifr) =3D=3D -1)
>  		err(1, "SIOCSETVLAN");
> @@ -117,7 +173,7 @@
>  		err(1, "SIOCGETVLAN");
> =20
>  	strncpy(vreq.vlr_parent, val, sizeof(vreq.vlr_parent));
> -	vreq.vlr_tag =3D __tag;
> +	vreq.vlr_tag =3D EVL_MAKETAG(__tag, __pri, __cfi);
> =20
>  	if (ioctl(s, SIOCSETVLAN, (caddr_t)&ifr) =3D=3D -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))
> =20
>  /* 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;

This appears to be a no-op.  Is it needed?

>  };
>  #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 =3D 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 =3D EINVAL;
> -			break;
> -		}
> =20
>  		VLAN_LOCK();
>  		error =3D vlan_config(ifv, p);

--=20
Any statement of the form "X is the one, true Y" is FALSE.
PGP fingerprint 655D 519C 26A7 82E7 2529  9BF0 5D8E 8BE9 F238 1AD4

--J2SCkAp4GZ/dPZZf
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQFB9StWXY6L6fI4GtQRAjSRAJwJuhA1WoTNQCoLqpoKNw46G1Y9CgCg5VP6
sQQb1Bxqd9yHFZqUXgqS7E0=
=srEQ
-----END PGP SIGNATURE-----

--J2SCkAp4GZ/dPZZf--



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