Date: Fri, 5 Nov 1999 16:10:11 -0700 (MST) From: les@safety.net To: FreeBSD-gnats-submit@freebsd.org Subject: bin/14731: Changes to /sbin/ifconfig to support vlan interface configuration Message-ID: <199911052310.QAA29659@ns2.safety.net>
index | next in thread | raw e-mail
>Number: 14731
>Category: bin
>Synopsis: The kernel has vlan support but ifconfig won't config it
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Fri Nov 5 15:20:01 PST 1999
>Closed-Date:
>Last-Modified:
>Originator: Les Biffle
>Release: FreeBSD 3.3-RELEASE i386
>Organization:
Network Safety Corporation
>Environment:
All 3.3 platforms, I would guess
>Description:
There is vlan support in the ethernet stack, but the function
in ifconfig required to associate a vlan interface with its parent
interface and to specify the vlan number for the 802.1Q tag is
not present.
>How-To-Repeat:
Not applicable
>Fix:
I'm attaching context diffs for /usr/src/sbin/ifconfig/ifconfig.c and
the matching man page. These changes add a "parent" parameter to
the ifconfig command to configure the vlan interface for operation.
Context diff to add "parent" parameter.
====== cut ====== cut ====== cut ====== cut ====== cut ====== cut ======
*** ifconfig.c Fri Nov 5 11:44:00 1999
--- nifconfig.c Fri Nov 5 11:48:18 1999
***************
*** 53,58 ****
--- 53,60 ----
#include <net/if.h>
#include <net/if_var.h>
+ #include <net/ethernet.h>
+ #include <net/if_vlan_var.h>
#include <net/if_dl.h>
#include <net/if_types.h>
#include <net/route.h>
***************
*** 94,103 ****
--- 96,108 ----
struct ifreq ifr, ridreq;
struct ifaliasreq addreq;
+ struct vlanreq vlr;
struct sockaddr_in netmask;
struct netrange at_nr; /* AppleTalk net range */
char name[32];
+ char parent[32];
+ int tag;
int flags;
int metric;
int mtu;
***************
*** 125,130 ****
--- 130,136 ----
c_func setifaddr, setifbroadaddr, setifdstaddr, setifnetmask;
c_func setifipdst;
c_func setifflags, setifmetric, setifmtu;
+ c_func setparent;
#define NEXTARG 0xffffff
***************
*** 151,156 ****
--- 157,163 ----
#endif
{ "netmask", NEXTARG, setifnetmask },
{ "range", NEXTARG, setatrange },
+ { "parent", NEXTARG, setparent },
{ "phase", NEXTARG, setatphase },
{ "metric", NEXTARG, setifmetric },
{ "broadcast", NEXTARG, setifbroadaddr },
***************
*** 670,675 ****
--- 677,708 ----
}
void
+ setparent(val, dummy, s, afp)
+ const char *val;
+ int dummy __unused;
+ int s;
+ const struct afswtch *afp;
+ {
+ char *cp;
+
+ ifr.ifr_data = (caddr_t)&vlr;
+ if (ioctl(s, SIOCGETVLAN, (caddr_t)&ifr) < 0)
+ warn("ioctl (SIOCGETVLAN)");
+
+ strncpy(parent, val, sizeof (parent));
+ if ((cp = strchr(parent, ':')) == (char *)NULL) {
+ Perror("format");
+ }
+ *cp++ = '\0';
+
+ strncpy(ifr.ifr_name, name, sizeof (ifr.ifr_name));
+ strncpy(vlr.vlr_parent, parent, sizeof (vlr.vlr_parent));
+ vlr.vlr_tag = atoi(cp);
+ if (ioctl(s, SIOCSETVLAN, (caddr_t)&ifr) < 0)
+ warn("ioctl (set parent)");
+ }
+
+ void
setifmtu(val, dummy, s, afp)
const char *val;
int dummy __unused;
***************
*** 738,743 ****
--- 771,785 ----
printf(" metric %d", metric);
if (mtu)
printf(" mtu %d", mtu);
+ if (!strncmp(name, "vlan", 4)) {
+ ifr.ifr_data = (caddr_t)&vlr;
+ if (ioctl(s, SIOCGETVLAN, (caddr_t)&ifr) < 0) {
+ warn("ioctl (SIOCGETVLAN)");
+ }
+ if (strlen(vlr.vlr_parent))
+ printf(" parent %s:%d", vlr.vlr_parent, vlr.vlr_tag);
+
+ }
putchar('\n');
while (addrcount > 0) {
====== cut ====== cut ====== cut ====== cut ====== cut ====== cut ======
Context diff to add parent parameter to man page:
====== cut ====== cut ====== cut ====== cut ====== cut ====== cut ======
*** ifconfig.8 Fri Nov 5 11:51:44 1999
--- nifconfig.8 Fri Nov 5 12:02:48 1999
***************
*** 32,38 ****
.\" From: @(#)ifconfig.8 8.3 (Berkeley) 1/5/94
.\" $FreeBSD: src/sbin/ifconfig/ifconfig.8,v 1.18.2.1 1999/08/29 15:13:39 peter Exp $
.\"
! .Dd February 13, 1996
.Dt IFCONFIG 8
.Os BSD 4.2
.Sh NAME
--- 32,38 ----
.\" From: @(#)ifconfig.8 8.3 (Berkeley) 1/5/94
.\" $FreeBSD: src/sbin/ifconfig/ifconfig.8,v 1.18.2.1 1999/08/29 15:13:39 peter Exp $
.\"
! .Dd November 5, 1999
.Dt IFCONFIG 8
.Os BSD 4.2
.Sh NAME
***************
*** 261,266 ****
--- 261,275 ----
.\" for
.\" .Tn AFI
.\" 37 type addresses.
+ .It Cm parent Ar parent-interface:tag
+ .\" (Inet and ISO)
+ Assign a VLAN interface to a parent interface and specify the 802.1Q tag
+ that identifies the particular VLAN within the parent interface. For
+ example, "ifconfig vlan0 parent fxp0:3" will flag vlan interface vlan0
+ as VLAN 3 on the fxp0 interface. Packets transmitted and received via
+ vlan0 will have an 802.1Q tag containing "3" between the normal ethernet
+ header and the payload, and vlan0 will assume the hardware address of
+ interface fxp0.
.It Cm range
Under appletalk, set the interface to respond to a
.Em netrange.
>Release-Note:
>Audit-Trail:
>Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199911052310.QAA29659>
