Hello community, here is the log from the commit of package vlan checked in at Fri Oct 27 19:25:15 CEST 2006. -------- --- vlan/vlan.changes 2006-03-29 13:58:36.000000000 +0200 +++ /mounts/work_src_done/STABLE/vlan/vlan.changes 2006-10-27 15:56:06.000000000 +0200 @@ -1,0 +2,9 @@ +Fri Oct 27 15:55:07 CEST 2006 - poeml@suse.de + +- update to 1.9: + - Fixed error exit codes to be !0 (makes it behave much better in + scripts. + - there are also changes in macvlan_config.c, which we don't + package though. + +------------------------------------------------------------------- Old: ---- vlan.1.8.tar.bz2 New: ---- vlan.1.9.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ vlan.spec ++++++ --- /var/tmp/diff_new_pack.V4woNx/_old 2006-10-27 19:24:53.000000000 +0200 +++ /var/tmp/diff_new_pack.V4woNx/_new 2006-10-27 19:24:53.000000000 +0200 @@ -1,5 +1,5 @@ # -# spec file for package vlan (Version 1.8) +# spec file for package vlan (Version 1.9) # # Copyright (c) 2006 SUSE LINUX Products GmbH, Nuernberg, Germany. # This file and all modifications and additions to the pristine @@ -13,13 +13,13 @@ Name: vlan BuildRequires: gcc-c++ URL: http://www.candelatech.com/~greear/vlan.html -Version: 1.8 -Release: 34 +Version: 1.9 +Release: 1 Summary: 802.1q VLAN Implementation for Linux -License: GPL +License: GNU General Public License (GPL) - all versions Group: Productivity/Networking/Other Autoreqprov: on -Source: http://scry.wanfear.com/~greear/vlan/vlan.%{version}.tar.bz2 +Source: http://www.candelatech.com/~greear/vlan/vlan.%{version}.tar.bz2 Source1: http://scry.wanfear.com/~greear/vlan/cisco_howto.html.bz2 Source2: README.SuSE BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -55,6 +55,12 @@ %attr(555,root,root) %{_sbindir}/vconfig %changelog -n vlan +* Fri Oct 27 2006 - poeml@suse.de +- update to 1.9: + - Fixed error exit codes to be !0 (makes it behave much better in + scripts. + - there are also changes in macvlan_config.c, which we don't + package though. * Wed Mar 29 2006 - poeml@suse.de - updated README for usage of hardware descriptions for ETHERDEVICE [#150771] ++++++ vlan.1.8.tar.bz2 -> vlan.1.9.tar.bz2 ++++++ diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/vlan/CHANGELOG new/vlan/CHANGELOG --- old/vlan/CHANGELOG 2003-09-30 23:01:55.000000000 +0200 +++ new/vlan/CHANGELOG 2005-08-09 22:59:16.000000000 +0200 @@ -1,5 +1,9 @@ This file should be prepended to each time a release is made. +Date: Aug 9, 2005 +Changes: Fixed error exit codes to be !0 (makes it behave much + better in scripts. + Date: Sept 30, 2003 Version: 1.8 Kernel Version: 2.4.21+ diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/vlan/MakeInclude new/vlan/MakeInclude --- old/vlan/MakeInclude 2003-08-25 19:08:18.000000000 +0200 +++ new/vlan/MakeInclude 2006-03-01 02:56:24.000000000 +0100 @@ -16,7 +16,7 @@ endif ## You may need to change this linux/include part. -CCFLAGS = -g -D_GNU_SOURCE -Wall -I${HOME}/linux/include +CCFLAGS = -g -D_GNU_SOURCE -Wall -I${HOME}/git/linux-2.6/include -I${HOME}/linux/include LDLIBS = # -lm #-lnsl # -lsocket ARM_TC_BIN = ${HOME}/Intrinsyc/bin diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/vlan/Makefile new/vlan/Makefile --- old/vlan/Makefile 2003-09-30 23:04:14.000000000 +0200 +++ new/vlan/Makefile 2006-03-02 19:17:11.000000000 +0100 @@ -11,7 +11,7 @@ VCONFIG = vconfig #program to be created -all: ${VCONFIG} macvlan_config +all: ${VCONFIG} mvl_config #This is pretty silly.. @@ -23,7 +23,7 @@ $(CC) $(CCFLAGS) $(LDFLAGS) -o $(VCONFIG) $(VLAN_OBJS) $(LDLIBS) $(STRIP) $(VCONFIG) -macvlan_config: macvlan_config.c +mvl_config: macvlan_config.c $(CC) $(CCFLAGS) $(LDFLAGS) -o $@ $< $(ALL_OBJS): %.o: %.c %.h @@ -35,7 +35,7 @@ rm -f *.o purge: clean - rm -f *.flc ${VCONFIG} macvlan_config vconfig.h + rm -f *.flc ${VCONFIG} mvl_config macvlan_config vconfig.h rm -f *~ diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/vlan/contrib/README new/vlan/contrib/README --- old/vlan/contrib/README 2001-06-19 00:28:23.000000000 +0200 +++ new/vlan/contrib/README 2003-10-01 01:22:05.000000000 +0200 @@ -5,6 +5,16 @@ If any of these seem particularly stable or useful, let me know and I will consider adding them to the main patch. +Descriptions: +network + "Thanks for the great vconfig patch/tool. I submit to you a minor + change to the RedHat 7.3 /etc/rc.d/init.d/network script that + recognizes VLAN interfaces /etc/sysconfig/network-scripts/ifcfg-ethx.y , + and makes appropriate calls to vconfig prior to bringing the + interface up. This makes startup more straightforward, + and may be of use to your website visitors. + -Derek" -Thanks, -Ben Greear (greearb@candelatech.com) + + + Thanks, Ben Greear (greearb@candelatech.com) diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/vlan/contrib/network new/vlan/contrib/network --- old/vlan/contrib/network 1970-01-01 01:00:00.000000000 +0100 +++ new/vlan/contrib/network 2003-10-01 01:22:05.000000000 +0200 @@ -0,0 +1,288 @@ +#! /bin/bash +# +# network Bring up/down networking +# +# chkconfig: 2345 10 90 +# description: Activates/Deactivates all network interfaces configured to \ +# start at boot time. +# probe: true +### BEGIN INIT INFO +# Provides: $network +### END INIT INFO + +# Source function library. + +. /etc/init.d/functions + +if [ ! -f /etc/sysconfig/network ]; then + exit 0 +fi + +. /etc/sysconfig/network + +if [ -f /etc/sysconfig/pcmcia ]; then + . /etc/sysconfig/pcmcia +fi + + +# Check that networking is up. +[ "${NETWORKING}" = "no" ] && exit 0 + +# if the ip configuration utility isn't around we can't function. +[ -x /sbin/ip ] || exit 1 + +# Even if IPX is configured, without the utilities we can't do much +[ ! -x /sbin/ipx_internal_net -o ! -x /sbin/ipx_configure ] && IPX= + +# If IPv6 is explicitly configured, make sure it's available. +if [ "$NETWORKING_IPV6" = "yes" ]; then + alias=`modprobe -c | awk '/^alias net-pf-10 / { print $3 }'` + if [ "$alias" != "ipv6" -a ! -f /proc/net/if_inet6 ]; then + echo "alias net-pf-10 ipv6" >> /etc/modules.conf + fi +fi + +CWD=`pwd` +cd /etc/sysconfig/network-scripts + +. network-functions + +# find all the interfaces besides loopback. +# ignore aliases, alternative configurations, and editor backup files +interfaces=`ls ifcfg* | LANG=C egrep -v '(ifcfg-lo|:|\.|rpmsave|rpmorig|rpmnew)' | \ + LANG=C egrep -v '(~|\.bak)$' | \ + LANG=C egrep 'ifcfg-[A-Za-z0-9_-]+$' | \ + sed 's/^ifcfg-//g'` + +vlan_interfaces=`ls ifcfg-eth?.?* | \ + LANG=C egrep -v '(~|\.bak)$' | \ + LANG=C egrep 'ifcfg-[A-Za-z0-9_-\.]+$' | \ + sed 's/^ifcfg-//g'` + +# See how we were called. +case "$1" in + start) + # IPv6 hook (pre IPv4 start) + if [ "$NETWORKING_IPV6" = "yes" ]; then + if [ -x /etc/sysconfig/network-scripts/init.ipv6-global ]; then + /etc/sysconfig/network-scripts/init.ipv6-global start pre + fi + fi + + action $"Setting network parameters: " sysctl -e -p /etc/sysctl.conf + + # bring up loopback interface + action $"Bringing up loopback interface: " ./ifup ifcfg-lo + + case "$IPX" in + yes|true) + /sbin/ipx_configure --auto_primary=$IPXAUTOPRIMARY \ + --auto_interface=$IPXAUTOFRAME + if [ "$IPXINTERNALNETNUM" != "0" ]; then + /sbin/ipx_internal_net add $IPXINTERNALNETNUM $IPXINTERNALNODENUM + fi + ;; + esac + + oldhotplug=`sysctl kernel.hotplug 2>/dev/null | \ + awk '{ print $3 }' 2>/dev/null` + sysctl -w kernel.hotplug="/bin/true" > /dev/null 2>&1 + + cipeinterfaces="" + + # bring up all other interfaces configured to come up at boot time + for i in $interfaces; do + eval $(fgrep "DEVICE=" ifcfg-$i) + if [ -z "$DEVICE" ] ; then DEVICE="$i"; fi + + if [ "${DEVICE##cipcb}" != "$DEVICE" ] ; then + cipeinterfaces="$cipeinterfaces $DEVICE" + continue + fi + if LANG=C egrep -L "^ONBOOT=\"?[Nn][Oo]\"?" ifcfg-$i > /dev/null ; then + # this loads the module, to preserve ordering + is_available $i + continue + fi + # If we're in confirmation mode, get user confirmation + [ -n "$CONFIRM" ] && + { + confirm $i + case $? in + 0) + : + ;; + 2) + CONFIRM= + ;; + *) + continue + ;; + esac + } + + action $"Bringing up interface $i: " ./ifup $i boot + done + + # bring up vlan interfaces configured to come up at boot time + for i in $vlan_interfaces; do + eval $(fgrep "DEVICE=" ifcfg-$i) + if [ -z "$DEVICE" ] ; then DEVICE="$i"; fi + + if LANG=C egrep -L "^ONBOOT=\"?[Nn][Oo]\"?" ifcfg-$i > /dev/null ; then + # this loads the module, to preserve ordering + is_available $i + continue + fi + # If we're in confirmation mode, get user confirmation + [ -n "$CONFIRM" ] && + { + confirm $i + case $? in + 0) + : + ;; + 2) + CONFIRM= + ;; + *) + continue + ;; + esac + } + /usr/local/bin/vconfig add `echo $i | tr '.' ' '` + action $"Bringing up interface $i: " ./ifup $i boot + done + + # Bring up CIPE VPN interfaces + for i in $cipeinterfaces ; do + if ! LANG=C egrep -L "^ONBOOT=\"?[Nn][Oo]\"?" ifcfg-$i >/dev/null 2>&1 ; then + # If we're in confirmation mode, get user confirmation + [ -n "$CONFIRM" ] && + { + confirm $i + case $? in + 0) + : + ;; + 2) + CONFIRM= + ;; + *) + continue + ;; + esac + } + action $"Bringing up interface $i: " ./ifup $i boot + fi + done + + sysctl -w kernel.hotplug=$oldhotplug > /dev/null 2>&1 + + # Add non interface-specific static-routes. + if [ -f /etc/sysconfig/static-routes ]; then + grep "^any" /etc/sysconfig/static-routes | while read ignore args ; do + /sbin/route add -$args + done + fi + + # IPv6 hook (post IPv4 start) + if [ "$NETWORKING_IPV6" = "yes" ]; then + if [ -x /etc/sysconfig/network-scripts/init.ipv6-global ]; then + /etc/sysconfig/network-scripts/init.ipv6-global start post + fi + fi + # Run this again to catch any interface-specific actions + sysctl -e -p /etc/sysctl.conf >/dev/null 2>&1 + + touch /var/lock/subsys/network + ;; + stop) + # If this is a final shutdown/halt, check for network FS, + # and unmount them even if the user didn't turn on netfs + + if [ "$RUNLEVEL" = "6" -o "$RUNLEVEL" = "0" -o "$RUNLEVEL" = "1" ]; then + NFSMTAB=`grep -v '^#' /proc/mounts | awk '{ if ($3 ~ /^nfs$/ ) print $2}'` + SMBMTAB=`grep -v '^#' /proc/mounts | awk '{ if ($3 ~ /^smbfs$/ ) print $2}'` + NCPMTAB=`grep -v '^#' /proc/mounts | awk '{ if ($3 ~ /^ncpfs$/ ) print $2}'` + if [ -n "$NFSMTAB" -o -n "$SMBMTAB" -o -n "$NCPMTAB" ] ; then + /etc/init.d/netfs stop + fi + fi + + # IPv6 hook (pre IPv4 stop) + if [ "$NETWORKING_IPV6" = "yes" ]; then + if [ -x /etc/sysconfig/network-scripts/init.ipv6-global ]; then + /etc/sysconfig/network-scripts/init.ipv6-global stop pre + fi + fi + + # shut down all interfaces (other than loopback) + for i in $interfaces ; do + eval $(fgrep "DEVICE=" ifcfg-$i) + if [ -z "$DEVICE" ] ; then DEVICE="$i"; fi + + if ! check_device_down $i; then + action $"Shutting down interface $i: " ./ifdown $i boot + fi + done + # VLAN + for i in $vlan_interfaces ; do + eval $(fgrep "DEVICE=" ifcfg-$i) + if [ -z "$DEVICE" ] ; then DEVICE="$i"; fi + + if [ -f /proc/net/vlan/$i ]; then + action $"Removing vlan interface interface $i: " /usr/local/bin/vconfig rem $i + fi + done + + case "$IPX" in + yes|true) + if [ "$IPXINTERNALNETNUM" != "0" ]; then + /sbin/ipx_internal_net del + fi + ;; + esac + + action $"Shutting down loopback interface: " ./ifdown ifcfg-lo + + if [ -d /proc/sys/net/ipv4 ]; then + if [ -f /proc/sys/net/ipv4/ip_forward ]; then + if [ `cat /proc/sys/net/ipv4/ip_forward` != 0 ]; then + action $"Disabling IPv4 packet forwarding: " sysctl -w net.ipv4.ip_forward=0 + fi + fi + if [ -f /proc/sys/net/ipv4/ip_always_defrag ]; then + if [ `cat /proc/sys/net/ipv4/ip_always_defrag` != 0 ]; then + action $"Disabling IPv4 automatic defragmentation: " sysctl -w net.ipv4.ip_always_defrag=0 + fi + fi + fi + + # IPv6 hook (post IPv4 stop) + if [ "$NETWORKING_IPV6" = "yes" ]; then + if [ -x /etc/sysconfig/network-scripts/init.ipv6-global ]; then + /etc/sysconfig/network-scripts/init.ipv6-global stop post + fi + fi + + rm -f /var/lock/subsys/network + ;; + status) + echo $"Configured devices:" + echo lo $interfaces + + echo $"Currently active devices:" + echo `/sbin/ip -o link show | awk -F ": " '{ print $2 }'` + ;; + restart|reload) + cd $CWD + $0 stop + $0 start + ;; + *) + echo $"Usage: $0 {start|stop|restart|reload|status}" + exit 1 +esac + +exit 0 Binary files old/vlan/macvlan_config and new/vlan/macvlan_config differ diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/vlan/macvlan_config.c new/vlan/macvlan_config.c --- old/vlan/macvlan_config.c 2003-08-12 21:36:36.000000000 +0200 +++ new/vlan/macvlan_config.c 2006-08-04 18:54:22.000000000 +0200 @@ -74,8 +74,10 @@ #include <string.h> #include <errno.h> +#define MVL_VERSION "2.0" -int do_help(int argc, char *argv[]); + +int _do_help(int argc, char *argv[]); int do_enable(int argc, char *argv[]); int do_disable(int argc, char *argv[]); int do_add(int argc, char *argv[]); @@ -92,7 +94,7 @@ int (*fn)(int argc, char *argv[]); char *long_help; } command_list[] = { - {"help", "help on other commands", do_help, "help <command>"}, + {"help", "help on other commands", _do_help, "help <command>"}, {"enable", "enables mac based vlans over an ethernet device", do_enable, "enable <ifname>\n" " - enables mac based vlans over \"ifname\"\n" @@ -103,20 +105,12 @@ "add <ifname> <index>\n" " - creates a new mac based vlan called \"ifname#index\" layered over \"ifname\"\n" " - mac based vlans over \"ifname\" must first be enabled with \"enable\"\n" - " - \"ifname#index\" is not mapped to any MAC address until \"bind\" is called" + " - \"ifname#index\" will have a random MAC address by default. Change with 'ifconfig' or 'ip'.\n" }, {"del", "destroys a mac based vlan", do_del, "del <ifname>\n" " - deletes a mac base vlan called \"ifname\"" }, - {"bind", "binds macaddr to vlan", do_bind, - "bind <ifname> <macaddr>\n" - " - binds macaddr to vlan called \"ifname\"" - }, - {"unbind", "unbinds macaddr from vlan", do_unbind, - "unbind <ifname> <macaddr>\n" - " - unbinds macaddr from vlan called \"ifname\"" - }, {"unload", "Unconfigure all of the macvlan devices", do_unload, "Unconfigure all of the macvlan devices so module can be unloaded"}, {"setflags", "Set port flags on a port", @@ -134,20 +128,37 @@ } -int do_help(int argc, char *argv[]) -{ - unsigned int cmd; - if (argc < 2) - return -1; - - for (cmd = 0; cmd < NCOMMANDS; cmd++) { - if (!strcmp(command_list[cmd].name,argv[1])) +int do_help(char *cmd) { + int i; + printf("version: %s\n", MVL_VERSION); + printf("sizeof(macvlan_ioctl): %d\n", (int)(sizeof(struct macvlan_ioctl))); + + if (cmd) { + for (i = 0; i < NCOMMANDS; i++) { + if (!strcmp(command_list[i].name, cmd)) break; - } - if (cmd == NCOMMANDS) - return -1; - puts(command_list[cmd].long_help); - return 0; + } + if (i == NCOMMANDS) + return -1; + puts(command_list[i].long_help); + } + else { + printf("\nsubcommands:\n\n"); + for (i = 0; i < NCOMMANDS; i++) { + printf("%s:\t%s\n", command_list[i].name, + command_list[i].short_help); + } + } + return 0; +} + +int _do_help(int argc, char *argv[]) { + if (argc < 2) { + return do_help(NULL); + } + else { + return do_help(argv[1]); + } } int do_enable(int argc, char *argv[]) @@ -166,10 +177,11 @@ } req.cmd = MACVLAN_ENABLE; - req.ifname = argv[1]; /* - * name of ethernet device over which we - * are enabling mac based vlans - */ + /* + * name of ethernet device over which we + * are enabling mac based vlans + */ + strncpy(req.ifname, argv[1], sizeof(req.ifname)); if (ioctl(s, SIOCGIFMACVLAN, &req) < 0) { if (errno != EEXIST) { @@ -201,10 +213,9 @@ } req.cmd = MACVLAN_SET_PORT_FLAGS; - req.ifname = argv[1]; /* - * name of ethernet device over which we - * are enabling mac based vlans - */ + /* name of macvlan device. */ + strncpy(req.ifname, argv[1], sizeof(req.ifname)); + req.ifidx = parseInt(argv[2]); if(ioctl(s, SIOCGIFMACVLAN, &req) < 0) { @@ -218,10 +229,9 @@ struct macvlan_ioctl req; req.cmd = MACVLAN_DISABLE; - req.ifname = port; /* - * name of ethernet device over which we - * are disabling mac based vlans - */ + + /* name of macvlan device. */ + strncpy(req.ifname, port, sizeof(req.ifname)); if(ioctl(s, SIOCGIFMACVLAN, &req) < 0) { perror("disable-port"); @@ -233,8 +243,7 @@ return 0; } -int do_disable(int argc, char *argv[]) -{ +int do_disable(int argc, char *argv[]) { int s; if (argc < 2) { @@ -250,8 +259,7 @@ return _do_disable(argv[1], s); } -int do_add(int argc, char *argv[]) -{ +int do_add(int argc, char *argv[]) { int s; struct macvlan_ioctl req; @@ -266,7 +274,8 @@ } req.cmd = MACVLAN_ADD; - req.ifname = argv[1]; /* name of lower layer i/f over which we are adding an upper layer i/f */ + /* name of lower layer i/f over which we are adding an upper layer i/f */ + strncpy(req.ifname, argv[1], sizeof(req.ifname)); req.ifidx = parseInt(argv[2]); if(ioctl(s, SIOCGIFMACVLAN, &req) < 0) { @@ -280,7 +289,8 @@ struct macvlan_ioctl req; req.cmd = MACVLAN_DEL; - req.ifname = ifname; /* name mac based vlan to destroy */ + /* name mac based vlan to destroy */ + strncpy(req.ifname, ifname, sizeof(req.ifname)); if(ioctl(s, SIOCGIFMACVLAN, &req) < 0) { printf("failed to delete interface: %s\n", ifname); @@ -294,8 +304,7 @@ return 0; } -int do_del(int argc, char *argv[]) -{ +int do_del(int argc, char *argv[]) { int s; if (argc < 2) { @@ -315,41 +324,36 @@ int get_num_ports(int s) { struct macvlan_ioctl req; - struct macvlan_ioctl_reply rep; req.cmd = MACVLAN_GET_NUM_PORTS; - req.reply = &rep; if(ioctl(s, SIOCGIFMACVLAN, &req) < 0) { perror("ioctl (SIOCGIFMACVLAN, GET_NUM_PORTS)"); return -1; } - printf("Found: %i ports\n", rep.num); + printf("Found: %i ports\n", req.reply.num); - return rep.num; + return req.reply.num; } int get_num_vlans(int portidx, int s) { struct macvlan_ioctl req; - struct macvlan_ioctl_reply rep; /* Get the number of mac-based-vlans layered * over this ethernet device */ req.cmd = MACVLAN_GET_NUM_VLANS; req.portidx = portidx; - req.reply = &rep; if(ioctl(s, SIOCGIFMACVLAN, &req) < 0) { perror("ioctl (GET_NUM_VLANS)"); return -1; } - printf("Found: %i vlans for port: %i\n", rep.num, portidx); - return rep.num; + printf("Found: %i vlans for port: %i\n", req.reply.num, portidx); + return req.reply.num; } -int htoi(char *s) -{ +int htoi(char *s) { char ch; int i = 0; while ((ch = *s++)) { @@ -359,106 +363,13 @@ return i; } -int do_bind(int argc, char *argv[]) -{ +int do_info(int argc, char *argv[]) { int s; struct macvlan_ioctl req; - char *ptr; - unsigned char macaddr[6]; - - if (argc < 3) { - printf("usage: %s <ifname> <macaddr>\n", argv[0]); - return 1; - } - - if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - perror("socket"); - return 1; - } - - req.cmd = MACVLAN_BIND; - req.ifname = argv[1]; /* name of vlan to which we are binding a MAC address */ - - /* assemble the macaddr */ - ptr = argv[2]; - if (strlen(ptr) != 17) { - printf("bad macaddr format: need aa:bb:cc:dd:ee:ff\n"); - return 1; - } - for (ptr = argv[2]+2; ptr < argv[2]+16; ptr+=3) - *ptr = 0; - ptr = argv[2]; - macaddr[0] = (unsigned char)htoi(ptr); - macaddr[1] = (unsigned char)htoi(ptr+3); - macaddr[2] = (unsigned char)htoi(ptr+6); - macaddr[3] = (unsigned char)htoi(ptr+9); - macaddr[4] = (unsigned char)htoi(ptr+12); - macaddr[5] = (unsigned char)htoi(ptr+15); - req.macaddr = macaddr; - - if(ioctl(s, SIOCGIFMACVLAN, &req) < 0) { - perror("ioctl (MACVLAN_BIND)"); - return 1; - } - return 0; -} - -int do_unbind(int argc, char *argv[]) -{ - int s; - struct macvlan_ioctl req; - char *ptr; - unsigned char macaddr[6]; - - if (argc < 3) { - printf("usage: %s <ifname> <macaddr>\n", argv[0]); - return 1; - } - - if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - perror("socket"); - return 1; - } - - req.cmd = MACVLAN_UNBIND; - req.ifname = argv[1]; /* name of vlan from which we are deleting a MAC address */ - - /* assemble the macaddr */ - ptr = argv[2]; - if (strlen(ptr) != 17) { - printf("bad macaddr format: need aa:bb:cc:dd:ee:ff\n"); - return 1; - } - for (ptr = argv[2]+2; ptr < argv[2]+16; ptr+=3) - *ptr = 0; - ptr = argv[2]; - macaddr[0] = (unsigned char)htoi(ptr); - macaddr[1] = (unsigned char)htoi(ptr+3); - macaddr[2] = (unsigned char)htoi(ptr+6); - macaddr[3] = (unsigned char)htoi(ptr+9); - macaddr[4] = (unsigned char)htoi(ptr+12); - macaddr[5] = (unsigned char)htoi(ptr+15); - req.macaddr = macaddr; - - if(ioctl(s, SIOCGIFMACVLAN, &req) < 0) { - perror("ioctl (MACVLAN_UNBIND)"); - return 1; - } - return 0; -} - -int do_info(int argc, char *argv[]) -{ - int s; - struct macvlan_ioctl req; - struct macvlan_ioctl_reply rep; int nports; int portidx; int nifs; int ifidx; - int nmacs; - int macidx; - unsigned char *p; if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) { perror("socket"); @@ -468,12 +379,11 @@ * enabled over them */ req.cmd = MACVLAN_GET_NUM_PORTS; - req.reply = &rep; if(ioctl(s, SIOCGIFMACVLAN, &req) < 0) { perror("ioctl (GET_NUM_PORTS)"); return 1; } - nports = rep.num; + nports = req.reply.num; for (portidx = 0; portidx < nports; portidx++) { char tmpifname[64]; /* Get the name of this mac-based-vlan enabled @@ -481,134 +391,57 @@ */ req.cmd = MACVLAN_GET_PORT_NAME; req.portidx = portidx; - req.reply = &rep; if(ioctl(s, SIOCGIFMACVLAN, &req) < 0) { perror("ioctl (GET_PORT_NAME)"); return 1; } - printf("-%s\n", rep.name); + printf("-%s\n", req.reply.name); /* get the port flags */ req.cmd = MACVLAN_GET_PORT_FLAGS; req.portidx = portidx; - strcpy(tmpifname, rep.name); - req.ifname = tmpifname; - req.reply = &rep; + strcpy(tmpifname, req.reply.name); + strncpy(req.ifname, tmpifname, sizeof(req.ifname)); if(ioctl(s, SIOCGIFMACVLAN, &req) < 0) { perror("ioctl (GET_PORT_FLAGS)"); return 1; } - printf("-%s flag: 0x%x\n", tmpifname, rep.num); + printf("-%s flag: 0x%x\n", tmpifname, req.reply.num); /* Get the number of mac-based-vlans layered * over this ethernet device */ req.cmd = MACVLAN_GET_NUM_VLANS; req.portidx = portidx; - req.reply = &rep; if(ioctl(s, SIOCGIFMACVLAN, &req) < 0) { perror("ioctl (GET_NUM_VLANS)"); return 1; } - nifs = rep.num; + nifs = req.reply.num; for (ifidx = 0; ifidx < nifs; ifidx++) { /* Get the name of this vlan */ req.cmd = MACVLAN_GET_VLAN_NAME; req.portidx = portidx; req.ifidx = ifidx; - req.reply = &rep; if(ioctl(s, SIOCGIFMACVLAN, &req) < 0) { perror("ioctl (GET_VLAN_NAME)"); return 1; } - /* get the number of mac addresses owned by this vlan */ - printf(" |-%s\n", rep.name); - req.cmd = MACVLAN_GET_NUM_MACS; - req.portidx = portidx; - req.ifidx = ifidx; - req.reply = &rep; - if(ioctl(s, SIOCGIFMACVLAN, &req) < 0) { - perror("ioctl (GET_NUM_MACS)"); - return 1; - } - nmacs = rep.num; - for (macidx = 0; macidx < nmacs; macidx++) { - /* get the value of this mac address */ - req.cmd = MACVLAN_GET_MAC_NAME; - req.portidx = portidx; - req.ifidx = ifidx; - req.macaddridx = macidx; - req.reply = &rep; - if(ioctl(s, SIOCGIFMACVLAN, &req) < 0) { - perror("ioctl (GET_MAC_NAME)"); - return 1; - } - p = (unsigned char *) rep.name; - printf(" | |-%02x:%02x:%02x:%02x:%02x:%02x\n", - p[0],p[1],p[2],p[3],p[4],p[5]); - } + /* print the name */ + printf(" |-%s\n", req.reply.name); } } return 0; } -int do_unload(int argc, char *argv[]) -{ - int s; - struct macvlan_ioctl req; - struct macvlan_ioctl_reply rep; - - if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - perror("socket"); - return 1; - } +int do_unload(int argc, char *argv[]) { - while (get_num_ports(s) > 0) { - char port[64]; - /* Get the name of this mac-based-vlan enabled - * ethernet device - */ - req.cmd = MACVLAN_GET_PORT_NAME; - req.portidx = 0; - req.reply = &rep; - if(ioctl(s, SIOCGIFMACVLAN, &req) < 0) { - perror("ioctl (GET_PORT_NAME)"); - return 1; - } - strcpy(port, rep.name); - - while (get_num_vlans(0, s) > 0) { - char cmd[128]; - /* Get the name of this vlan */ - req.cmd = MACVLAN_GET_VLAN_NAME; - req.portidx = 0; - req.ifidx = 0; - req.reply = &rep; - if(ioctl(s, SIOCGIFMACVLAN, &req) < 0) { - perror("ioctl (GET_VLAN_NAME)"); - return 1; - } - - /* Configure down the vlan */ - /* This would be faster using IOCTLs, of course! */ - printf("Configuring down interface: %s with ifconfig...", rep.name); - sprintf(cmd, "ifconfig %s down", rep.name); - system(cmd); - - /* Now, can remove it */ - _do_del(rep.name, s); - } - - /* Now, remove the port */ - _do_disable(port, s); - - } - return 0; + // Just unload the module + return system("rmmod macvlan"); } -int main(int argc, char *argv[]) -{ +int main(int argc, char *argv[]) { unsigned int cmd; int err; @@ -627,9 +460,6 @@ return 0; usage: - printf("\n%s subcommands:\n\n", argv[0]); - for (cmd = 0; cmd < NCOMMANDS; cmd++) { - printf("%s %s:\t%s\n",argv[0],command_list[cmd].name,command_list[cmd].short_help); - } + do_help(NULL); return err; } Binary files old/vlan/mvl_config and new/vlan/mvl_config differ Binary files old/vlan/vconfig and new/vlan/vconfig differ diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/vlan/vconfig.c new/vlan/vconfig.c --- old/vlan/vconfig.c 2003-08-01 00:43:08.000000000 +0200 +++ new/vlan/vconfig.c 2005-08-09 22:49:25.000000000 +0200 @@ -132,7 +132,7 @@ } else { // MATHIEU - //cerr << "Invalid name type.\n"; + //cerr << "Invalid name type.\n"; fprintf(stderr,"Invalid name type.\n"); show_usage(); @@ -144,10 +144,9 @@ if_name = argv[2]; if (strlen(if_name) > 15) { // MATHIEU - //cerr << "ERROR: if_name must be 15 characters or less." << endl; - fprintf(stderr,"ERROR: if_name must be 15 characters or less.\n"); - - exit(1); + //cerr << "ERROR: if_name must be 15 characters or less." << endl; + fprintf(stderr,"ERROR: if_name must be 15 characters or less.\n"); + exit(1); } strcpy(if_request.device1, if_name); } @@ -187,7 +186,8 @@ if_request.cmd = ADD_VLAN_CMD; if (ioctl(fd, SIOCSIFVLAN, &if_request) < 0) { fprintf(stderr,"ERROR: trying to add VLAN #%u to IF -:%s:- error: %s\n", - vid, if_name, strerror(errno)); + vid, if_name, strerror(errno)); + exit(3); } else { fprintf(stdout,"Added VLAN with VID == %u to IF -:%s:-\n", @@ -201,7 +201,8 @@ if_request.cmd = DEL_VLAN_CMD; if (ioctl(fd, SIOCSIFVLAN, &if_request) < 0) { fprintf(stderr,"ERROR: trying to remove VLAN -:%s:- error: %s\n", - if_name, strerror(errno)); + if_name, strerror(errno)); + exit(4); } else { fprintf(stdout,"Removed VLAN -:%s:-\n", if_name); @@ -211,7 +212,8 @@ if_request.cmd = SET_VLAN_EGRESS_PRIORITY_CMD; if (ioctl(fd, SIOCSIFVLAN, &if_request) < 0) { fprintf(stderr,"ERROR: trying to set egress map on device -:%s:- error: %s\n", - if_name, strerror(errno)); + if_name, strerror(errno)); + exit(5); } else { fprintf(stdout,"Set egress mapping on device -:%s:- " @@ -224,6 +226,7 @@ if (ioctl(fd, SIOCSIFVLAN, &if_request) < 0) { fprintf(stderr,"ERROR: trying to set ingress map on device -:%s:- error: %s\n", if_name, strerror(errno)); + exit(6); } else { fprintf(stdout,"Set ingress mapping on device -:%s:- " @@ -236,6 +239,7 @@ if (ioctl(fd, SIOCSIFVLAN, &if_request) < 0) { fprintf(stderr,"ERROR: trying to set flag on device -:%s:- error: %s\n", if_name, strerror(errno)); + exit(7); } else { fprintf(stdout,"Set flag on device -:%s:- " @@ -247,7 +251,8 @@ if_request.cmd = SET_VLAN_NAME_TYPE_CMD; if (ioctl(fd, SIOCSIFVLAN, &if_request) < 0) { fprintf(stderr,"ERROR: trying to set name type for VLAN subsystem, error: %s\n", - strerror(errno)); + strerror(errno)); + exit(8); } else { fprintf(stdout,"Set name-type for VLAN subsystem." Binary files old/vlan/vconfig.o and new/vlan/vconfig.o differ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Remember to have fun... --------------------------------------------------------------------- To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-commit+help@opensuse.org
participants (1)
-
root@suse.de