diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2009-11-22 22:00:25 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2009-11-22 22:00:25 +0000 |
commit | e77b0b834bacf5c44e7aff10e896a1d6edbdffdd (patch) | |
tree | ff16125e7af743556cfc6033b683f7ba81207680 /sbin/ifconfig/ifconfig.c | |
parent | 7ca08619b56402edd8da07eda10d344165040869 (diff) |
Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@
Diffstat (limited to 'sbin/ifconfig/ifconfig.c')
-rw-r--r-- | sbin/ifconfig/ifconfig.c | 90 |
1 files changed, 70 insertions, 20 deletions
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index 79dffb5f8e8..cc8888c5e93 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ifconfig.c,v 1.222 2009/11/22 18:45:19 claudio Exp $ */ +/* $OpenBSD: ifconfig.c,v 1.223 2009/11/22 22:00:24 claudio Exp $ */ /* $NetBSD: ifconfig.c,v 1.40 1997/10/01 02:19:43 enami Exp $ */ /* @@ -104,6 +104,8 @@ #include <unistd.h> #include <ifaddrs.h> +#include "brconfig.h" + struct ifreq ifr, ridreq; struct in_aliasreq in_addreq; #ifdef INET6 @@ -324,6 +326,10 @@ const struct cmd { { "ipdst", NEXTARG, 0, setifipdst }, { "prefixlen", NEXTARG, 0, setifprefixlen}, { "priority", NEXTARG, 0, setpriority }, + { "vlan", NEXTARG, 0, setvlantag }, + { "vlanprio", NEXTARG, 0, setvlanprio }, + { "vlandev", NEXTARG, 0, setvlandev }, + { "-vlandev", 1, 0, unsetvlandev }, #ifdef INET6 { "anycast", IN6_IFF_ANYCAST, 0, setia6flags }, { "-anycast", -IN6_IFF_ANYCAST, 0, setia6flags }, @@ -339,12 +345,6 @@ const struct cmd { { "range", NEXTARG, 0, setatrange }, { "phase", NEXTARG, 0, setatphase }, { "mplslabel", NEXTARG, 0, setmpelabel }, -#endif /* SMALL */ - { "vlan", NEXTARG, 0, setvlantag }, - { "vlanprio", NEXTARG, 0, setvlanprio }, - { "vlandev", NEXTARG, 0, setvlandev }, - { "-vlandev", 1, 0, unsetvlandev }, -#ifndef SMALL { "advbase", NEXTARG, 0, setcarp_advbase }, { "advskew", NEXTARG, 0, setcarp_advskew }, { "carppeer", NEXTARG, 0, setcarppeer }, @@ -392,6 +392,54 @@ const struct cmd { { "nwflag", NEXTARG, 0, setifnwflag }, { "-nwflag", NEXTARG, 0, unsetifnwflag }, { "rdomain", NEXTARG, 0, setinstance }, + { "flowsrc", NEXTARG, 0, setpflow_sender }, + { "-flowsrc", 1, 0, unsetpflow_sender }, + { "flowdst", NEXTARG, 0, setpflow_receiver }, + { "-flowdst", 1, 0, unsetpflow_receiver }, + { "-inet6", IFXF_NOINET6, 0, setifxflags } , + { "add", NEXTARG, 0, bridge_add }, + { "del", NEXTARG, 0, bridge_delete }, + { "addspan", NEXTARG, 0, bridge_addspan }, + { "delspan", NEXTARG, 0, bridge_delspan }, + { "discover", NEXTARG, 0, setdiscover }, + { "-discover", NEXTARG, 0, unsetdiscover }, + { "blocknonip", NEXTARG, 0, setblocknonip }, + { "-blocknonip",NEXTARG, 0, unsetblocknonip }, + { "learn", NEXTARG, 0, setlearn }, + { "-learn", NEXTARG, 0, unsetlearn }, + { "stp", NEXTARG, 0, setstp }, + { "-stp", NEXTARG, 0, unsetstp }, + { "edge", NEXTARG, 0, setedge }, + { "-edge", NEXTARG, 0, unsetedge }, + { "autoedge", NEXTARG, 0, setautoedge }, + { "-autoedge", NEXTARG, 0, unsetautoedge }, + { "ptp", NEXTARG, 0, setptp }, + { "-ptp", NEXTARG, 0, unsetptp }, + { "autoptp", NEXTARG, 0, setautoptp }, + { "-autoptp", NEXTARG, 0, unsetautoptp }, + { "flush", 0, 0, bridge_flush }, + { "flushall", 0, 0, bridge_flushall }, + { "static", NEXTARG2, 0, NULL, bridge_addaddr }, + { "deladdr", NEXTARG, 0, bridge_deladdr }, + { "maxaddr", NEXTARG, 0, bridge_maxaddr }, + { "addr", 0, 0, bridge_addrs }, + { "hellotime", NEXTARG, 0, bridge_hellotime }, + { "fwddelay", NEXTARG, 0, bridge_fwddelay }, + { "maxage", NEXTARG, 0, bridge_maxage }, + { "proto", NEXTARG, 0, bridge_proto }, + { "ifpriority", NEXTARG2, 0, NULL, bridge_ifprio }, + { "ifcost", NEXTARG2, 0, NULL, bridge_ifcost }, + { "-ifcost", NEXTARG, 0, bridge_noifcost }, + { "timeout", NEXTARG, 0, bridge_timeout }, + { "holdcnt", NEXTARG, 0, bridge_holdcnt }, + { "spanpriority", NEXTARG, 0, bridge_priority }, +#if 0 + /* XXX `rule` special-cased below */ + { "rule", 0, 0, bridge_rule }, +#endif + { "rules", NEXTARG, 0, bridge_rules }, + { "rulefile", NEXTARG, 0, bridge_rulefile }, + { "flushrule", NEXTARG, 0, bridge_flushrule }, #endif /* SMALL */ #if 0 /* XXX `create' special-cased below */ @@ -415,13 +463,6 @@ const struct cmd { { "descr", NEXTARG, 0, setifdesc }, { "-description", 1, 0, unsetifdesc }, { "-descr", 1, 0, unsetifdesc }, -#ifndef SMALL - { "flowsrc", NEXTARG, 0, setpflow_sender }, - { "-flowsrc", 1, 0, unsetpflow_sender }, - { "flowdst", NEXTARG, 0, setpflow_receiver }, - { "-flowdst", 1, 0, unsetpflow_receiver }, - { "-inet6", IFXF_NOINET6, 0, setifxflags } , -#endif { NULL, /*src*/ 0, 0, setifaddr }, { NULL, /*dst*/ 0, 0, setifdstaddr }, { NULL, /*illegal*/0, 0, NULL }, @@ -611,6 +652,13 @@ main(int argc, char *argv[]) for (p = cmds; p->c_name; p++) if (strcmp(*argv, p->c_name) == 0) break; +#ifndef SMALL + if (strcmp(*argv, "rule") == 0) { + argc--, argv++; + bridge_rule(argc, argv, -1); + return; + } +#endif if (p->c_name == 0 && setaddr) for (i = setaddr; i > 0; i--) { p++; @@ -742,7 +790,11 @@ getinfo(struct ifreq *ifr, int create) metric = 0; else metric = ifr->ifr_metric; +#ifdef SMALL if (ioctl(s, SIOCGIFMTU, (caddr_t)ifr) < 0) +#else + if (is_bridge(name) || ioctl(s, SIOCGIFMTU, (caddr_t)ifr) < 0) +#endif mtu = 0; else mtu = ifr->ifr_mtu; @@ -2564,10 +2616,6 @@ print_media_word(int ifmw, int print_type, int as_syntax) printf(" instance %d", IFM_INST(ifmw)); } -#define IFFBITS \ -"\020\1UP\2BROADCAST\3DEBUG\4LOOPBACK\5POINTOPOINT\6NOTRAILERS\7RUNNING\10NOARP\ -\11PROMISC\12ALLMULTI\13OACTIVE\14SIMPLEX\15LINK0\16LINK1\17LINK2\20MULTICAST" - /* ARGSUSED */ static void phys_status(int force) @@ -2653,9 +2701,8 @@ status(int link, struct sockaddr_dl *sdl) printf("\tdescription: %s\n", ifrdesc.ifr_data); #ifndef SMALL - if (ioctl(s, SIOCGIFPRIORITY, &ifrdesc) == 0) + if (!is_bridge(name) && ioctl(s, SIOCGIFPRIORITY, &ifrdesc) == 0) printf("\tpriority: %d\n", ifrdesc.ifr_metric); - #endif vlan_status(); #ifndef SMALL @@ -2767,6 +2814,9 @@ status(int link, struct sockaddr_dl *sdl) } phys_status(0); +#ifndef SMALL + bridge_status(); +#endif } /* ARGSUSED */ |