diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2009-06-04 19:07:22 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2009-06-04 19:07:22 +0000 |
commit | 1041db1394aeef25c3a5a21180b36441f477c69a (patch) | |
tree | 0c5d5a2a574e12211bcf1561030bb841ac068dc0 /sbin/ifconfig/ifconfig.c | |
parent | 649412d634e24b58b17a4a685c72317b709a7114 (diff) |
allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk
Diffstat (limited to 'sbin/ifconfig/ifconfig.c')
-rw-r--r-- | sbin/ifconfig/ifconfig.c | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index 76380705865..ecb22b1aae5 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ifconfig.c,v 1.215 2009/04/27 22:52:55 deraadt Exp $ */ +/* $OpenBSD: ifconfig.c,v 1.216 2009/06/04 19:07:21 henning Exp $ */ /* $NetBSD: ifconfig.c,v 1.40 1997/10/01 02:19:43 enami Exp $ */ /* @@ -142,6 +142,7 @@ void setifrtlabel(const char *, int); void setiflladdr(const char *, int); void setifdstaddr(const char *, int); void setifflags(const char *, int); +void setifxflags(const char *, int); void setifbroadaddr(const char *, int); void setifdesc(const char *, int); void unsetifdesc(const char *, int); @@ -411,6 +412,7 @@ const struct cmd { { "-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 }, @@ -501,6 +503,7 @@ main(int argc, char *argv[]) int Cflag = 0; int gflag = 0; int i; + int noprint = 0; /* If no args at all, print all interfaces. */ if (argc < 2) { @@ -589,6 +592,12 @@ main(int argc, char *argv[]) create = (argc > 0) && strcmp(argv[0], "destroy") != 0; (void)getinfo(&ifr, create); } +#ifdef INET6 + if (argc == 0 && af == AF_INET6) + noprint = 1; /* handles "ifconfig <if> inet6" */ + if (af == AF_INET6) + setifxflags("inet6", -IFXF_NOINET6); +#endif while (argc > 0) { const struct cmd *p; @@ -644,7 +653,7 @@ nextarg: argc--, argv++; } - if (argc == 0 && actions == 0) { + if (argc == 0 && actions == 0 && !noprint) { printif(ifr.ifr_name, 1); exit(0); } @@ -1113,6 +1122,29 @@ setifflags(const char *vname, int value) err(1, "SIOCSIFFLAGS"); } +/* ARGSUSED */ +void +setifxflags(const char *vname, int value) +{ + struct ifreq my_ifr; + + bcopy((char *)&ifr, (char *)&my_ifr, sizeof(struct ifreq)); + + if (ioctl(s, SIOCGIFXFLAGS, (caddr_t)&my_ifr) < 0) + warn("SIOCGIFXFLAGS"); + (void) strlcpy(my_ifr.ifr_name, name, sizeof(my_ifr.ifr_name)); + flags = my_ifr.ifr_flags; + + if (value < 0) { + value = -value; + flags &= ~value; + } else + flags |= value; + my_ifr.ifr_flags = flags; + if (ioctl(s, SIOCSIFXFLAGS, (caddr_t)&my_ifr) < 0) + warn("SIOCSIFXFLAGS"); +} + #ifdef INET6 void setia6flags(const char *vname, int value) |