2 * SPDX-License-Identifier: BSD-3-Clause
4 * Copyright (c) 1983, 1993
5 * The Regents of the University of California. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 static const char copyright[] =
34 "@(#) Copyright (c) 1983, 1993\n\
35 The Regents of the University of California. All rights reserved.\n";
37 static char sccsid[] = "@(#)ifconfig.c 8.2 (Berkeley) 2/16/94";
39 static const char rcsid[] =
43 #include <sys/param.h>
44 #include <sys/ioctl.h>
45 #include <sys/module.h>
46 #include <sys/linker.h>
48 #include <sys/queue.h>
49 #include <sys/socket.h>
52 #include <net/ethernet.h>
54 #include <net/if_dl.h>
55 #include <net/if_types.h>
56 #include <net/route.h>
59 #include <netinet/in.h>
60 #include <netinet/in_var.h>
61 #include <arpa/inet.h>
79 #include <libifconfig.h>
83 ifconfig_handle_t *lifh;
86 * Since "struct ifreq" is composed of various union members, callers
87 * should pay special attention to interpret the value.
88 * (.e.g. little/big endian difference in the structure.)
105 int printkeys = 0; /* Print keying material for interfaces. */
108 /* Formatter Strings */
109 char *f_inet, *f_inet6, *f_ether, *f_addr;
111 static bool group_member(const char *ifname, const char *match,
112 const char *nomatch);
113 static int ifconfig(int argc, char *const *argv, int iscreate,
114 const struct afswtch *afp);
115 static void status(const struct afswtch *afp, const struct sockaddr_dl *sdl,
116 struct ifaddrs *ifa);
117 static void tunnel_status(int s);
118 static _Noreturn void usage(void);
120 static int getifflags(const char *ifname, int us, bool err_ok);
122 static struct afswtch *af_getbyname(const char *name);
123 static struct afswtch *af_getbyfamily(int af);
124 static void af_other_status(int);
126 void printifnamemaybe(void);
128 static struct option *opts = NULL;
130 struct ifa_order_elt {
134 TAILQ_ENTRY(ifa_order_elt) link;
137 TAILQ_HEAD(ifa_queue, ifa_order_elt);
139 static struct module_map_entry {
145 .kldname = "if_tuntap",
149 .kldname = "if_tuntap",
153 .kldname = "if_tuntap",
161 * This mapping exists because there is a conflicting enc module
162 * in CAM. ifconfig's guessing behavior will attempt to match
163 * the ifname to a module as well as if_${ifname} and clash with
164 * CAM enc. This is an assertion of the correct module to load.
173 opt_register(struct option *p)
185 /* XXX not right but close enough for now */
187 for (p = opts; p != NULL; p = p->next) {
188 strlcat(options, p->opt_usage, sizeof(options));
189 strlcat(options, " ", sizeof(options));
193 "usage: ifconfig [-f type:format] %sinterface address_family\n"
194 " [address [dest_address]] [parameters]\n"
195 " ifconfig interface create\n"
196 " ifconfig -a %s[-d] [-m] [-u] [-v] [address_family]\n"
197 " ifconfig -l [-d] [-u] [address_family]\n"
198 " ifconfig %s[-d] [-m] [-u] [-v]\n",
199 options, options, options);
204 ioctl_ifcreate(int s, struct ifreq *ifr)
206 if (ioctl(s, SIOCIFCREATE2, ifr) < 0) {
209 errx(1, "interface %s already exists", ifr->ifr_name);
211 err(1, "SIOCIFCREATE2 (%s)", ifr->ifr_name);
217 calcorders(struct ifaddrs *ifa, struct ifa_queue *q)
219 struct ifaddrs *prev;
220 struct ifa_order_elt *cur;
221 unsigned int ord, af, ifa_ord;
228 while (ifa != NULL) {
230 strcmp(ifa->ifa_name, prev->ifa_name) != 0) {
231 cur = calloc(1, sizeof(*cur));
236 TAILQ_INSERT_TAIL(q, cur, link);
237 cur->if_order = ifa_ord ++;
243 af = ifa->ifa_addr->sa_family;
245 if (af < nitems(cur->af_orders) &&
246 cur->af_orders[af] == 0)
247 cur->af_orders[af] = ++ord;
257 cmpifaddrs(struct ifaddrs *a, struct ifaddrs *b, struct ifa_queue *q)
259 struct ifa_order_elt *cur, *e1, *e2;
260 unsigned int af1, af2;
265 ret = strcmp(a->ifa_name, b->ifa_name);
267 TAILQ_FOREACH(cur, q, link) {
271 if (strcmp(cur->ifa->ifa_name, a->ifa_name) == 0)
273 else if (strcmp(cur->ifa->ifa_name, b->ifa_name) == 0)
280 return (e1->if_order - e2->if_order);
282 } else if (a->ifa_addr != NULL && b->ifa_addr != NULL) {
283 TAILQ_FOREACH(cur, q, link) {
284 if (strcmp(cur->ifa->ifa_name, a->ifa_name) == 0) {
293 af1 = a->ifa_addr->sa_family;
294 af2 = b->ifa_addr->sa_family;
296 if (af1 < nitems(e1->af_orders) && af2 < nitems(e1->af_orders))
297 return (e1->af_orders[af1] - e1->af_orders[af2]);
303 static void freeformat(void)
316 static void setformat(char *input)
318 char *formatstr, *category, *modifier;
320 formatstr = strdup(input);
321 while ((category = strsep(&formatstr, ",")) != NULL) {
322 modifier = strchr(category, ':');
323 if (modifier == NULL || modifier[1] == '\0') {
324 warnx("Skipping invalid format specification: %s\n",
329 /* Split the string on the separator, then seek past it */
333 if (strcmp(category, "addr") == 0)
334 f_addr = strdup(modifier);
335 else if (strcmp(category, "ether") == 0)
336 f_ether = strdup(modifier);
337 else if (strcmp(category, "inet") == 0)
338 f_inet = strdup(modifier);
339 else if (strcmp(category, "inet6") == 0)
340 f_inet6 = strdup(modifier);
345 static struct ifaddrs *
346 sortifaddrs(struct ifaddrs *list,
347 int (*compare)(struct ifaddrs *, struct ifaddrs *, struct ifa_queue *),
350 struct ifaddrs *right, *temp, *last, *result, *next, *tail;
359 if (!list || !list->ifa_next)
362 while (temp && temp->ifa_next) {
364 right = right->ifa_next;
365 temp = temp->ifa_next->ifa_next;
368 last->ifa_next = NULL;
370 list = sortifaddrs(list, compare, q);
371 right = sortifaddrs(right, compare, q);
373 while (list || right) {
377 list = list->ifa_next;
380 right = right->ifa_next;
381 } else if (compare(list, right, q) <= 0) {
383 list = list->ifa_next;
386 right = right->ifa_next;
392 tail->ifa_next = next;
400 void printifnamemaybe()
403 printf("%s\n", name);
407 main(int argc, char *argv[])
409 int c, all, namesonly, downonly, uponly;
410 const struct afswtch *afp = NULL;
412 struct ifaddrs *ifap, *sifap, *ifa;
414 const struct sockaddr_dl *sdl;
415 char options[1024], *cp, *envformat, *namecp = NULL;
416 struct ifa_queue q = TAILQ_HEAD_INITIALIZER(q);
417 struct ifa_order_elt *cur, *tmp;
418 const char *ifname, *matchgroup, *nogroup;
423 all = downonly = uponly = namesonly = noload = verbose = 0;
424 f_inet = f_inet6 = f_ether = f_addr = NULL;
425 matchgroup = nogroup = NULL;
427 lifh = ifconfig_open();
429 err(EXIT_FAILURE, "ifconfig_open");
431 envformat = getenv("IFCONFIG_FORMAT");
432 if (envformat != NULL)
433 setformat(envformat);
436 * Ensure we print interface name when expected to,
437 * even if we terminate early due to error.
439 atexit(printifnamemaybe);
441 /* Parse leading line options */
442 strlcpy(options, "G:adf:klmnuv", sizeof(options));
443 for (p = opts; p != NULL; p = p->next)
444 strlcat(options, p->opt, sizeof(options));
445 while ((c = getopt(argc, argv, options)) != -1) {
447 case 'a': /* scan all interfaces */
450 case 'd': /* restrict scan to "down" interfaces */
459 if (optarg == NULL || all == 0)
466 case 'l': /* scan interface names only */
469 case 'm': /* show media choices in status */
472 case 'n': /* suppress module loading */
475 case 'u': /* restrict scan to "up" interfaces */
490 for (p = opts; p != NULL; p = p->next)
491 if (p->opt[0] == c) {
503 /* -l cannot be used with -a or -m */
504 if (namesonly && (all || supmedia))
508 if (uponly && downonly)
511 /* no arguments is equivalent to '-a' */
512 if (!namesonly && argc < 1)
515 /* -a and -l allow an address family arg to limit the output */
516 if (all || namesonly) {
523 afp = af_getbyname(*argv);
525 warnx("Address family '%s' unknown.", *argv);
528 if (afp->af_name != NULL)
530 /* leave with afp non-zero */
533 /* not listing, need an argument */
540 /* check and maybe load support for this interface */
543 ifindex = if_nametoindex(ifname);
546 * NOTE: We must special-case the `create' command
547 * right here as we would otherwise fail when trying
548 * to find the interface.
550 if (argc > 0 && (strcmp(argv[0], "create") == 0 ||
551 strcmp(argv[0], "plumb") == 0)) {
552 iflen = strlcpy(name, ifname, sizeof(name));
553 if (iflen >= sizeof(name))
554 errx(1, "%s: cloning name too long",
556 ifconfig(argc, argv, 1, NULL);
561 * NOTE: We have to special-case the `-vnet' command
562 * right here as we would otherwise fail when trying
563 * to find the interface as it lives in another vnet.
565 if (argc > 0 && (strcmp(argv[0], "-vnet") == 0)) {
566 iflen = strlcpy(name, ifname, sizeof(name));
567 if (iflen >= sizeof(name))
568 errx(1, "%s: interface name too long",
570 ifconfig(argc, argv, 0, NULL);
574 errx(1, "interface %s does not exist", ifname);
577 * Do not allow use `create` command as hostname if
578 * address family is not specified.
580 if (argc > 0 && (strcmp(argv[0], "create") == 0 ||
581 strcmp(argv[0], "plumb") == 0)) {
583 errx(1, "interface %s already exists",
590 /* Check for address family */
592 afp = af_getbyname(*argv);
598 * Check for a requested configuration action on a single interface,
599 * which doesn't require building, sorting, and searching the entire
600 * system address list
602 if ((argc > 0) && (ifname != NULL)) {
603 iflen = strlcpy(name, ifname, sizeof(name));
604 if (iflen >= sizeof(name)) {
605 warnx("%s: interface name too long, skipping", ifname);
607 flags = getifflags(name, -1, false);
608 if (!(((flags & IFF_CANTCONFIG) != 0) ||
609 (downonly && (flags & IFF_UP) != 0) ||
610 (uponly && (flags & IFF_UP) == 0)))
611 ifconfig(argc, argv, 0, afp);
616 if (getifaddrs(&ifap) != 0)
617 err(EXIT_FAILURE, "getifaddrs");
621 if (calcorders(ifap, &q) != 0)
622 err(EXIT_FAILURE, "calcorders");
624 sifap = sortifaddrs(ifap, cmpifaddrs, &q);
626 TAILQ_FOREACH_SAFE(cur, &q, link, tmp)
630 for (ifa = sifap; ifa; ifa = ifa->ifa_next) {
631 memset(&paifr, 0, sizeof(paifr));
632 strlcpy(paifr.ifr_name, ifa->ifa_name, sizeof(paifr.ifr_name));
633 if (sizeof(paifr.ifr_addr) >= ifa->ifa_addr->sa_len) {
634 memcpy(&paifr.ifr_addr, ifa->ifa_addr,
635 ifa->ifa_addr->sa_len);
638 if (ifname != NULL && strcmp(ifname, ifa->ifa_name) != 0)
640 if (ifa->ifa_addr->sa_family == AF_LINK)
641 sdl = (const struct sockaddr_dl *) ifa->ifa_addr;
644 if (cp != NULL && strcmp(cp, ifa->ifa_name) == 0 && !namesonly)
646 iflen = strlcpy(name, ifa->ifa_name, sizeof(name));
647 if (iflen >= sizeof(name)) {
648 warnx("%s: interface name too long, skipping",
654 if ((ifa->ifa_flags & IFF_CANTCONFIG) != 0)
656 if (downonly && (ifa->ifa_flags & IFF_UP) != 0)
658 if (uponly && (ifa->ifa_flags & IFF_UP) == 0)
660 if (!group_member(ifa->ifa_name, matchgroup, nogroup))
663 * Are we just listing the interfaces?
669 /* special case for "ether" address family */
670 if (!strcmp(afp->af_name, "ether")) {
672 (sdl->sdl_type != IFT_ETHER &&
673 sdl->sdl_type != IFT_L2VLAN &&
674 sdl->sdl_type != IFT_BRIDGE) ||
675 sdl->sdl_alen != ETHER_ADDR_LEN)
678 if (ifa->ifa_addr->sa_family
693 ifconfig(argc, argv, 0, afp);
695 status(afp, sdl, ifa);
703 ifconfig_close(lifh);
708 * Returns true if an interface should be listed because any its groups
709 * matches shell pattern "match" and none of groups matches pattern "nomatch".
710 * If any pattern is NULL, corresponding condition is skipped.
713 group_member(const char *ifname, const char *match, const char *nomatch)
715 static int sock = -1;
717 struct ifgroupreq ifgr;
720 bool matched, nomatched;
723 if (match == NULL && nomatch == NULL)
728 memset(&ifgr, 0, sizeof(ifgr));
729 strlcpy(ifgr.ifgr_name, ifname, IFNAMSIZ);
731 /* The socket is opened once. Let _exit() close it. */
733 sock = socket(AF_LOCAL, SOCK_DGRAM, 0);
735 errx(1, "%s: socket(AF_LOCAL,SOCK_DGRAM)", __func__);
738 /* Determine amount of memory for the list of groups. */
739 if (ioctl(sock, SIOCGIFGROUP, (caddr_t)&ifgr) == -1) {
740 if (errno == EINVAL || errno == ENOTTY)
743 errx(1, "%s: SIOCGIFGROUP", __func__);
746 /* Obtain the list of groups. */
749 (struct ifg_req *)calloc(len / sizeof(*ifg), sizeof(*ifg));
751 if (ifgr.ifgr_groups == NULL)
752 errx(1, "%s: no memory", __func__);
753 if (ioctl(sock, SIOCGIFGROUP, (caddr_t)&ifgr) == -1)
754 errx(1, "%s: SIOCGIFGROUP", __func__);
756 /* Perform matching. */
759 for (ifg = ifgr.ifgr_groups; ifg && len >= sizeof(*ifg); ifg++) {
760 len -= sizeof(struct ifg_req);
762 matched |= !fnmatch(match, ifg->ifgrq_group, 0);
764 nomatched &= fnmatch(nomatch, ifg->ifgrq_group, 0);
766 free(ifgr.ifgr_groups);
768 if (match && !nomatch)
770 if (!match && nomatch)
772 return (matched && nomatched);
775 static struct afswtch *afs = NULL;
778 af_register(struct afswtch *p)
784 static struct afswtch *
785 af_getbyname(const char *name)
789 for (afp = afs; afp != NULL; afp = afp->af_next)
790 if (strcmp(afp->af_name, name) == 0)
795 static struct afswtch *
796 af_getbyfamily(int af)
800 for (afp = afs; afp != NULL; afp = afp->af_next)
801 if (afp->af_af == af)
807 af_other_status(int s)
810 uint8_t afmask[howmany(AF_MAX, NBBY)];
812 memset(afmask, 0, sizeof(afmask));
813 for (afp = afs; afp != NULL; afp = afp->af_next) {
814 if (afp->af_other_status == NULL)
816 if (afp->af_af != AF_UNSPEC && isset(afmask, afp->af_af))
818 afp->af_other_status(s);
819 setbit(afmask, afp->af_af);
824 af_all_tunnel_status(int s)
827 uint8_t afmask[howmany(AF_MAX, NBBY)];
829 memset(afmask, 0, sizeof(afmask));
830 for (afp = afs; afp != NULL; afp = afp->af_next) {
831 if (afp->af_status_tunnel == NULL)
833 if (afp->af_af != AF_UNSPEC && isset(afmask, afp->af_af))
835 afp->af_status_tunnel(s);
836 setbit(afmask, afp->af_af);
840 static struct cmd *cmds = NULL;
843 cmd_register(struct cmd *p)
849 static const struct cmd *
850 cmd_lookup(const char *name, int iscreate)
854 for (p = cmds; p != NULL; p = p->c_next)
855 if (strcmp(name, p->c_name) == 0) {
868 callback_func *cb_func;
870 struct callback *cb_next;
872 static struct callback *callbacks = NULL;
875 callback_register(callback_func *func, void *arg)
879 cb = malloc(sizeof(struct callback));
881 errx(1, "unable to allocate memory for callback");
884 cb->cb_next = callbacks;
888 /* specially-handled commands */
889 static void setifaddr(const char *, int, int, const struct afswtch *);
890 static const struct cmd setifaddr_cmd = DEF_CMD("ifaddr", 0, setifaddr);
892 static void setifdstaddr(const char *, int, int, const struct afswtch *);
893 static const struct cmd setifdstaddr_cmd =
894 DEF_CMD("ifdstaddr", 0, setifdstaddr);
897 ifconfig(int argc, char *const *argv, int iscreate, const struct afswtch *uafp)
899 const struct afswtch *afp, *nafp;
904 strlcpy(ifr.ifr_name, name, sizeof ifr.ifr_name);
909 * This is the historical "accident" allowing users to configure IPv4
910 * addresses without the "inet" keyword which while a nice feature has
911 * proven to complicate other things. We cannot remove this but only
912 * make sure we will never have a similar implicit default for IPv6 or
913 * any other address familiy. We need a fallback though for
914 * ifconfig IF up/down etc. to work without INET support as people
915 * never used ifconfig IF link up/down, etc. either.
919 if (afp == NULL && feature_present("inet"))
920 afp = af_getbyname("inet");
924 afp = af_getbyname("link");
926 warnx("Please specify an address_family.");
930 ifr.ifr_addr.sa_family =
931 afp->af_af == AF_LINK || afp->af_af == AF_UNSPEC ?
932 AF_LOCAL : afp->af_af;
934 if ((s = socket(ifr.ifr_addr.sa_family, SOCK_DGRAM, 0)) < 0 &&
935 (uafp != NULL || errno != EAFNOSUPPORT ||
936 (s = socket(AF_LOCAL, SOCK_DGRAM, 0)) < 0))
937 err(1, "socket(family %u,SOCK_DGRAM)", ifr.ifr_addr.sa_family);
940 p = cmd_lookup(*argv, iscreate);
941 if (iscreate && p == NULL) {
943 * Push the clone create callback so the new
944 * device is created and can be used for any
945 * remaining arguments.
949 errx(1, "internal error, no callback");
950 callbacks = cb->cb_next;
951 cb->cb_func(s, cb->cb_arg);
954 * Handle any address family spec that
955 * immediately follows and potentially
956 * recreate the socket.
958 nafp = af_getbyname(*argv);
968 * Look for a normal parameter.
974 * Not a recognized command, choose between setting
975 * the interface address and the dst address.
977 p = (setaddr ? &setifdstaddr_cmd : &setifaddr_cmd);
979 if (p->c_parameter == NEXTARG && p->c_u.c_func) {
981 errx(1, "'%s' requires argument",
983 p->c_u.c_func(argv[1], 0, s, afp);
985 } else if (p->c_parameter == OPTARG && p->c_u.c_func) {
986 p->c_u.c_func(argv[1], 0, s, afp);
989 } else if (p->c_parameter == NEXTARG2 && p->c_u.c_func2) {
991 errx(1, "'%s' requires 2 arguments",
993 p->c_u.c_func2(argv[1], argv[2], s, afp);
994 argc -= 2, argv += 2;
995 } else if (p->c_parameter == SPARAM && p->c_u.c_func3) {
996 p->c_u.c_func3(*argv, p->c_sparameter, s, afp);
997 } else if (p->c_u.c_func)
998 p->c_u.c_func(*argv, p->c_parameter, s, afp);
1003 * Do any post argument processing required by the address family.
1005 if (afp->af_postproc != NULL)
1006 afp->af_postproc(s, afp, newaddr, getifflags(name, s, true));
1008 * Do deferred callbacks registered while processing
1009 * command-line arguments.
1011 for (cb = callbacks; cb != NULL; cb = cb->cb_next)
1012 cb->cb_func(s, cb->cb_arg);
1014 * Do deferred operations.
1017 if (afp->af_ridreq == NULL || afp->af_difaddr == 0) {
1018 warnx("interface %s cannot change %s addresses!",
1019 name, afp->af_name);
1025 strlcpy(((struct ifreq *)afp->af_ridreq)->ifr_name, name,
1026 sizeof ifr.ifr_name);
1027 ret = ioctl(s, afp->af_difaddr, afp->af_ridreq);
1029 if (errno == EADDRNOTAVAIL && (doalias >= 0)) {
1030 /* means no previous address for interface */
1032 Perror("ioctl (SIOCDIFADDR)");
1036 if (afp->af_addreq == NULL || afp->af_aifaddr == 0) {
1037 warnx("interface %s cannot change %s addresses!",
1038 name, afp->af_name);
1042 if (newaddr && (setaddr || setmask)) {
1043 strlcpy(((struct ifreq *)afp->af_addreq)->ifr_name, name,
1044 sizeof ifr.ifr_name);
1045 if (ioctl(s, afp->af_aifaddr, afp->af_addreq) < 0)
1046 Perror("ioctl (SIOCAIFADDR)");
1055 setifaddr(const char *addr, int param, int s, const struct afswtch *afp)
1057 if (afp->af_getaddr == NULL)
1060 * Delay the ioctl to set the interface addr until flags are all set.
1061 * The address interpretation may depend on the flags,
1062 * and the flags may change when the address is set.
1065 if (doalias == 0 && afp->af_af != AF_LINK)
1067 afp->af_getaddr(addr, (doalias >= 0 ? ADDR : RIDADDR));
1071 settunnel(const char *src, const char *dst, int s, const struct afswtch *afp)
1073 struct addrinfo *srcres, *dstres;
1076 if (afp->af_settunnel == NULL) {
1077 warn("address family %s does not support tunnel setup",
1082 if ((ecode = getaddrinfo(src, NULL, NULL, &srcres)) != 0)
1083 errx(1, "error in parsing address string: %s",
1084 gai_strerror(ecode));
1086 if ((ecode = getaddrinfo(dst, NULL, NULL, &dstres)) != 0)
1087 errx(1, "error in parsing address string: %s",
1088 gai_strerror(ecode));
1090 if (srcres->ai_addr->sa_family != dstres->ai_addr->sa_family)
1092 "source and destination address families do not match");
1094 afp->af_settunnel(s, srcres, dstres);
1096 freeaddrinfo(srcres);
1097 freeaddrinfo(dstres);
1102 deletetunnel(const char *vname, int param, int s, const struct afswtch *afp)
1105 if (ioctl(s, SIOCDIFPHYADDR, &ifr) < 0)
1106 err(1, "SIOCDIFPHYADDR");
1111 setifvnet(const char *jname, int dummy __unused, int s,
1112 const struct afswtch *afp)
1114 struct ifreq my_ifr;
1116 memcpy(&my_ifr, &ifr, sizeof(my_ifr));
1117 my_ifr.ifr_jid = jail_getid(jname);
1118 if (my_ifr.ifr_jid < 0)
1119 errx(1, "%s", jail_errmsg);
1120 if (ioctl(s, SIOCSIFVNET, &my_ifr) < 0)
1121 err(1, "SIOCSIFVNET");
1125 setifrvnet(const char *jname, int dummy __unused, int s,
1126 const struct afswtch *afp)
1128 struct ifreq my_ifr;
1130 memcpy(&my_ifr, &ifr, sizeof(my_ifr));
1131 my_ifr.ifr_jid = jail_getid(jname);
1132 if (my_ifr.ifr_jid < 0)
1133 errx(1, "%s", jail_errmsg);
1134 if (ioctl(s, SIOCSIFRVNET, &my_ifr) < 0)
1135 err(1, "SIOCSIFRVNET(%d, %s)", my_ifr.ifr_jid, my_ifr.ifr_name);
1140 setifnetmask(const char *addr, int dummy __unused, int s,
1141 const struct afswtch *afp)
1143 if (afp->af_getaddr != NULL) {
1145 afp->af_getaddr(addr, MASK);
1150 setifbroadaddr(const char *addr, int dummy __unused, int s,
1151 const struct afswtch *afp)
1153 if (afp->af_getaddr != NULL)
1154 afp->af_getaddr(addr, DSTADDR);
1158 notealias(const char *addr, int param, int s, const struct afswtch *afp)
1160 #define rqtosa(x) (&(((struct ifreq *)(afp->x))->ifr_addr))
1161 if (setaddr && doalias == 0 && param < 0)
1162 if (afp->af_addreq != NULL && afp->af_ridreq != NULL)
1163 bcopy((caddr_t)rqtosa(af_addreq),
1164 (caddr_t)rqtosa(af_ridreq),
1165 rqtosa(af_addreq)->sa_len);
1177 setifdstaddr(const char *addr, int param __unused, int s,
1178 const struct afswtch *afp)
1180 if (afp->af_getaddr != NULL)
1181 afp->af_getaddr(addr, DSTADDR);
1185 getifflags(const char *ifname, int us, bool err_ok)
1187 struct ifreq my_ifr;
1190 memset(&my_ifr, 0, sizeof(my_ifr));
1191 (void) strlcpy(my_ifr.ifr_name, ifname, sizeof(my_ifr.ifr_name));
1193 if ((s = socket(AF_LOCAL, SOCK_DGRAM, 0)) < 0)
1194 err(1, "socket(family AF_LOCAL,SOCK_DGRAM");
1197 if (ioctl(s, SIOCGIFFLAGS, (caddr_t)&my_ifr) < 0) {
1199 Perror("ioctl (SIOCGIFFLAGS)");
1205 return ((my_ifr.ifr_flags & 0xffff) | (my_ifr.ifr_flagshigh << 16));
1209 * Note: doing an SIOCIGIFFLAGS scribbles on the union portion
1210 * of the ifreq structure, which may confuse other parts of ifconfig.
1211 * Make a private copy so we can avoid that.
1214 setifflags(const char *vname, int value, int s, const struct afswtch *afp)
1216 struct ifreq my_ifr;
1219 flags = getifflags(name, s, false);
1225 memset(&my_ifr, 0, sizeof(my_ifr));
1226 (void) strlcpy(my_ifr.ifr_name, name, sizeof(my_ifr.ifr_name));
1227 my_ifr.ifr_flags = flags & 0xffff;
1228 my_ifr.ifr_flagshigh = flags >> 16;
1229 if (ioctl(s, SIOCSIFFLAGS, (caddr_t)&my_ifr) < 0)
1234 setifcap(const char *vname, int value, int s, const struct afswtch *afp)
1238 if (ioctl(s, SIOCGIFCAP, (caddr_t)&ifr) < 0) {
1239 Perror("ioctl (SIOCGIFCAP)");
1242 flags = ifr.ifr_curcap;
1248 flags &= ifr.ifr_reqcap;
1249 /* Check for no change in capabilities. */
1250 if (ifr.ifr_curcap == flags)
1252 ifr.ifr_reqcap = flags;
1253 if (ioctl(s, SIOCSIFCAP, (caddr_t)&ifr) < 0)
1258 setifcapnv(const char *vname, const char *arg, int s, const struct afswtch *afp)
1266 if (ioctl(s, SIOCGIFCAP, (caddr_t)&ifr) < 0)
1267 Perror("ioctl (SIOCGIFCAP)");
1268 if ((ifr.ifr_curcap & IFCAP_NV) == 0) {
1269 warnx("IFCAP_NV not supported");
1270 return; /* Not exit() */
1276 nvcap = nvlist_create(0);
1278 Perror("nvlist_create");
1279 while ((mopt = strsep(&marg, ",")) != NULL) {
1283 if (strcmp(mopt, "rxtls") == 0) {
1284 nvlist_add_bool(nvcap, "rxtls4", !neg);
1285 nvlist_add_bool(nvcap, "rxtls6", !neg);
1287 nvlist_add_bool(nvcap, mopt, !neg);
1290 buf = nvlist_pack(nvcap, &nvbuflen);
1292 errx(1, "nvlist_pack error");
1295 ifr.ifr_cap_nv.buf_length = ifr.ifr_cap_nv.length = nvbuflen;
1296 ifr.ifr_cap_nv.buffer = buf;
1297 if (ioctl(s, SIOCSIFCAPNV, (caddr_t)&ifr) < 0)
1300 nvlist_destroy(nvcap);
1305 setifmetric(const char *val, int dummy __unused, int s,
1306 const struct afswtch *afp)
1308 strlcpy(ifr.ifr_name, name, sizeof (ifr.ifr_name));
1309 ifr.ifr_metric = atoi(val);
1310 if (ioctl(s, SIOCSIFMETRIC, (caddr_t)&ifr) < 0)
1311 err(1, "ioctl SIOCSIFMETRIC (set metric)");
1315 setifmtu(const char *val, int dummy __unused, int s,
1316 const struct afswtch *afp)
1318 strlcpy(ifr.ifr_name, name, sizeof (ifr.ifr_name));
1319 ifr.ifr_mtu = atoi(val);
1320 if (ioctl(s, SIOCSIFMTU, (caddr_t)&ifr) < 0)
1321 err(1, "ioctl SIOCSIFMTU (set mtu)");
1325 setifpcp(const char *val, int arg __unused, int s, const struct afswtch *afp)
1330 ul = strtoul(val, &endp, 0);
1332 errx(1, "invalid value for pcp");
1334 errx(1, "value for pcp out of range");
1335 ifr.ifr_lan_pcp = ul;
1336 if (ioctl(s, SIOCSLANPCP, (caddr_t)&ifr) == -1)
1337 err(1, "SIOCSLANPCP");
1341 disableifpcp(const char *val, int arg __unused, int s,
1342 const struct afswtch *afp)
1345 ifr.ifr_lan_pcp = IFNET_PCP_NONE;
1346 if (ioctl(s, SIOCSLANPCP, (caddr_t)&ifr) == -1)
1347 err(1, "SIOCSLANPCP");
1351 setifname(const char *val, int dummy __unused, int s,
1352 const struct afswtch *afp)
1356 strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
1358 newname = strdup(val);
1359 if (newname == NULL)
1360 err(1, "no memory to set ifname");
1361 ifr.ifr_data = newname;
1362 if (ioctl(s, SIOCSIFNAME, (caddr_t)&ifr) < 0) {
1364 err(1, "ioctl SIOCSIFNAME (set name)");
1367 strlcpy(name, newname, sizeof(name));
1373 setifdescr(const char *val, int dummy __unused, int s,
1374 const struct afswtch *afp)
1378 strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
1380 ifr.ifr_buffer.length = strlen(val) + 1;
1381 if (ifr.ifr_buffer.length == 1) {
1382 ifr.ifr_buffer.buffer = newdescr = NULL;
1383 ifr.ifr_buffer.length = 0;
1385 newdescr = strdup(val);
1386 ifr.ifr_buffer.buffer = newdescr;
1387 if (newdescr == NULL) {
1388 warn("no memory to set ifdescr");
1393 if (ioctl(s, SIOCSIFDESCR, (caddr_t)&ifr) < 0)
1394 err(1, "ioctl SIOCSIFDESCR (set descr)");
1401 unsetifdescr(const char *val, int value, int s, const struct afswtch *afp)
1404 setifdescr("", 0, s, 0);
1408 "\020\1UP\2BROADCAST\3DEBUG\4LOOPBACK\5POINTOPOINT\7RUNNING" \
1409 "\10NOARP\11PROMISC\12ALLMULTI\13OACTIVE\14SIMPLEX\15LINK0\16LINK1\17LINK2" \
1410 "\20MULTICAST\22PPROMISC\23MONITOR\24STATICARP\25STICKYARP"
1413 "\020\1RXCSUM\2TXCSUM\3NETCONS\4VLAN_MTU\5VLAN_HWTAGGING\6JUMBO_MTU\7POLLING" \
1414 "\10VLAN_HWCSUM\11TSO4\12TSO6\13LRO\14WOL_UCAST\15WOL_MCAST\16WOL_MAGIC" \
1415 "\17TOE4\20TOE6\21VLAN_HWFILTER\23VLAN_HWTSO\24LINKSTATE\25NETMAP" \
1416 "\26RXCSUM_IPV6\27TXCSUM_IPV6\31TXRTLMT\32HWRXTSTMP\33NOMAP\34TXTLS4\35TXTLS6" \
1417 "\36VXLAN_HWCSUM\37VXLAN_HWTSO\40TXTLS_RTLMT"
1420 * Print the status of the interface. If an address family was
1421 * specified, show only it; otherwise, show them all.
1424 status(const struct afswtch *afp, const struct sockaddr_dl *sdl,
1425 struct ifaddrs *ifa)
1427 struct ifaddrs *ift;
1432 int allfamilies, s, type;
1437 ifr.ifr_addr.sa_family = AF_LOCAL;
1440 ifr.ifr_addr.sa_family =
1441 afp->af_af == AF_LINK ? AF_LOCAL : afp->af_af;
1443 strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
1445 s = socket(ifr.ifr_addr.sa_family, SOCK_DGRAM, 0);
1447 err(1, "socket(family %u,SOCK_DGRAM)", ifr.ifr_addr.sa_family);
1449 printf("%s: ", name);
1450 printb("flags", ifa->ifa_flags, IFFBITS);
1451 if (ioctl(s, SIOCGIFMETRIC, &ifr) != -1)
1452 printf(" metric %d", ifr.ifr_metric);
1453 if (ioctl(s, SIOCGIFMTU, &ifr) != -1)
1454 printf(" mtu %d", ifr.ifr_mtu);
1458 if ((descr = reallocf(descr, descrlen)) != NULL) {
1459 ifr.ifr_buffer.buffer = descr;
1460 ifr.ifr_buffer.length = descrlen;
1461 if (ioctl(s, SIOCGIFDESCR, &ifr) == 0) {
1462 if (ifr.ifr_buffer.buffer == descr) {
1463 if (strlen(descr) > 0)
1464 printf("\tdescription: %s\n",
1466 } else if (ifr.ifr_buffer.length > descrlen) {
1467 descrlen = ifr.ifr_buffer.length;
1472 warn("unable to allocate memory for interface"
1477 if (ioctl(s, SIOCGIFCAP, (caddr_t)&ifr) == 0) {
1478 if ((ifr.ifr_curcap & IFCAP_NV) != 0) {
1479 buf = malloc(IFR_CAP_NV_MAXBUFSIZE);
1482 ifr.ifr_cap_nv.buffer = buf;
1483 ifr.ifr_cap_nv.buf_length = IFR_CAP_NV_MAXBUFSIZE;
1484 if (ioctl(s, SIOCGIFCAPNV, (caddr_t)&ifr) != 0)
1485 Perror("ioctl (SIOCGIFCAPNV)");
1486 nvcap = nvlist_unpack(ifr.ifr_cap_nv.buffer,
1487 ifr.ifr_cap_nv.length, 0);
1489 Perror("nvlist_unpack");
1490 printf("\toptions");
1492 for (first = true;; first = false) {
1493 nvname = nvlist_next(nvcap, &type, &cookie);
1494 if (nvname == NULL) {
1498 if (type == NV_TYPE_BOOL) {
1499 val = nvlist_get_bool(nvcap, nvname);
1502 first ? ' ' : ',', nvname);
1507 printf("\tcapabilities");
1509 for (first = true;; first = false) {
1510 nvname = nvlist_next(nvcap, &type,
1512 if (nvname == NULL) {
1516 if (type == NV_TYPE_BOOL)
1517 printf("%c%s", first ? ' ' :
1521 nvlist_destroy(nvcap);
1524 if (ioctl(s, SIOCGIFCAP, (caddr_t)&ifr) != 0)
1525 Perror("ioctl (SIOCGIFCAP)");
1526 } else if (ifr.ifr_curcap != 0) {
1527 printb("\toptions", ifr.ifr_curcap, IFCAPBITS);
1529 if (supmedia && ifr.ifr_reqcap != 0) {
1530 printb("\tcapabilities", ifr.ifr_reqcap,
1539 for (ift = ifa; ift != NULL; ift = ift->ifa_next) {
1540 if (ift->ifa_addr == NULL)
1542 if (strcmp(ifa->ifa_name, ift->ifa_name) != 0)
1545 const struct afswtch *p;
1546 p = af_getbyfamily(ift->ifa_addr->sa_family);
1547 if (p != NULL && p->af_status != NULL)
1548 p->af_status(s, ift);
1549 } else if (afp->af_af == ift->ifa_addr->sa_family)
1550 afp->af_status(s, ift);
1553 if (allfamilies || afp->af_af == AF_LINK) {
1554 const struct afswtch *lafp;
1557 * Hack; the link level address is received separately
1558 * from the routing information so any address is not
1559 * handled above. Cobble together an entry and invoke
1560 * the status method specially.
1562 lafp = af_getbyname("lladdr");
1564 info.rti_info[RTAX_IFA] = (struct sockaddr *)sdl;
1565 lafp->af_status(s, &info);
1571 else if (afp->af_other_status != NULL)
1572 afp->af_other_status(s);
1574 strlcpy(ifs.ifs_name, name, sizeof ifs.ifs_name);
1575 if (ioctl(s, SIOCGIFSTATUS, &ifs) == 0)
1576 printf("%s", ifs.ascii);
1579 sfp_status(s, &ifr, verbose);
1586 tunnel_status(int s)
1588 af_all_tunnel_status(s);
1592 Perror(const char *cmd)
1597 errx(1, "%s: no such interface", cmd);
1601 errx(1, "%s: permission denied", cmd);
1610 * Print a value a la the %b format of the kernel's printf
1613 printb(const char *s, unsigned v, const char *bits)
1618 if (bits && *bits == 8)
1619 printf("%s=%o", s, v);
1621 printf("%s=%x", s, v);
1625 while ((i = *bits++) != '\0') {
1626 if (v & (1u << (i-1))) {
1630 for (; (c = *bits) > 32; bits++)
1633 for (; *bits > 32; bits++)
1641 print_vhid(const struct ifaddrs *ifa, const char *s)
1643 struct if_data *ifd;
1645 if (ifa->ifa_data == NULL)
1648 ifd = ifa->ifa_data;
1649 if (ifd->ifi_vhid == 0)
1652 printf(" vhid %d", ifd->ifi_vhid);
1656 ifmaybeload(const char *name)
1658 #define MOD_PREFIX_LEN 3 /* "if_" */
1659 struct module_stat mstat;
1660 int i, fileid, modid;
1661 char ifkind[IFNAMSIZ + MOD_PREFIX_LEN], ifname[IFNAMSIZ], *dp;
1663 struct module_map_entry *mme;
1666 /* loading suppressed by the user */
1670 /* trim the interface number off the end */
1671 strlcpy(ifname, name, sizeof(ifname));
1672 for (dp = ifname; *dp != 0; dp++)
1678 /* Either derive it from the map or guess otherwise */
1681 for (i = 0; i < nitems(module_map); ++i) {
1682 mme = &module_map[i];
1683 if (strcmp(mme->ifname, ifname) == 0) {
1684 strlcpy(ifkind, mme->kldname, sizeof(ifkind));
1690 /* We didn't have an alias for it... we'll guess. */
1692 /* turn interface and unit into module name */
1693 strlcpy(ifkind, "if_", sizeof(ifkind));
1694 strlcat(ifkind, ifname, sizeof(ifkind));
1697 /* scan files in kernel */
1698 mstat.version = sizeof(struct module_stat);
1699 for (fileid = kldnext(0); fileid > 0; fileid = kldnext(fileid)) {
1700 /* scan modules in file */
1701 for (modid = kldfirstmod(fileid); modid > 0;
1702 modid = modfnext(modid)) {
1703 if (modstat(modid, &mstat) < 0)
1705 /* strip bus name if present */
1706 if ((cp = strchr(mstat.name, '/')) != NULL) {
1712 * Is it already loaded? Don't compare with ifname if
1713 * we were specifically told which kld to use. Doing
1714 * so could lead to conflicts not trivially solved.
1716 if ((!found && strcmp(ifname, cp) == 0) ||
1717 strcmp(ifkind, cp) == 0)
1723 * Try to load the module. But ignore failures, because ifconfig can't
1724 * infer the names of all drivers (eg mlx4en(4)).
1726 (void) kldload(ifkind);
1729 static struct cmd basic_cmds[] = {
1730 DEF_CMD("up", IFF_UP, setifflags),
1731 DEF_CMD("down", -IFF_UP, setifflags),
1732 DEF_CMD("arp", -IFF_NOARP, setifflags),
1733 DEF_CMD("-arp", IFF_NOARP, setifflags),
1734 DEF_CMD("debug", IFF_DEBUG, setifflags),
1735 DEF_CMD("-debug", -IFF_DEBUG, setifflags),
1736 DEF_CMD_ARG("description", setifdescr),
1737 DEF_CMD_ARG("descr", setifdescr),
1738 DEF_CMD("-description", 0, unsetifdescr),
1739 DEF_CMD("-descr", 0, unsetifdescr),
1740 DEF_CMD("promisc", IFF_PPROMISC, setifflags),
1741 DEF_CMD("-promisc", -IFF_PPROMISC, setifflags),
1742 DEF_CMD("add", IFF_UP, notealias),
1743 DEF_CMD("alias", IFF_UP, notealias),
1744 DEF_CMD("-alias", -IFF_UP, notealias),
1745 DEF_CMD("delete", -IFF_UP, notealias),
1746 DEF_CMD("remove", -IFF_UP, notealias),
1748 #define EN_SWABIPS 0x1000
1749 DEF_CMD("swabips", EN_SWABIPS, setifflags),
1750 DEF_CMD("-swabips", -EN_SWABIPS, setifflags),
1752 DEF_CMD_ARG("netmask", setifnetmask),
1753 DEF_CMD_ARG("metric", setifmetric),
1754 DEF_CMD_ARG("broadcast", setifbroadaddr),
1755 DEF_CMD_ARG2("tunnel", settunnel),
1756 DEF_CMD("-tunnel", 0, deletetunnel),
1757 DEF_CMD("deletetunnel", 0, deletetunnel),
1759 DEF_CMD_ARG("vnet", setifvnet),
1760 DEF_CMD_ARG("-vnet", setifrvnet),
1762 DEF_CMD("link0", IFF_LINK0, setifflags),
1763 DEF_CMD("-link0", -IFF_LINK0, setifflags),
1764 DEF_CMD("link1", IFF_LINK1, setifflags),
1765 DEF_CMD("-link1", -IFF_LINK1, setifflags),
1766 DEF_CMD("link2", IFF_LINK2, setifflags),
1767 DEF_CMD("-link2", -IFF_LINK2, setifflags),
1768 DEF_CMD("monitor", IFF_MONITOR, setifflags),
1769 DEF_CMD("-monitor", -IFF_MONITOR, setifflags),
1770 DEF_CMD("mextpg", IFCAP_MEXTPG, setifcap),
1771 DEF_CMD("-mextpg", -IFCAP_MEXTPG, setifcap),
1772 DEF_CMD("staticarp", IFF_STATICARP, setifflags),
1773 DEF_CMD("-staticarp", -IFF_STATICARP, setifflags),
1774 DEF_CMD("stickyarp", IFF_STICKYARP, setifflags),
1775 DEF_CMD("-stickyarp", -IFF_STICKYARP, setifflags),
1776 DEF_CMD("rxcsum6", IFCAP_RXCSUM_IPV6, setifcap),
1777 DEF_CMD("-rxcsum6", -IFCAP_RXCSUM_IPV6, setifcap),
1778 DEF_CMD("txcsum6", IFCAP_TXCSUM_IPV6, setifcap),
1779 DEF_CMD("-txcsum6", -IFCAP_TXCSUM_IPV6, setifcap),
1780 DEF_CMD("rxcsum", IFCAP_RXCSUM, setifcap),
1781 DEF_CMD("-rxcsum", -IFCAP_RXCSUM, setifcap),
1782 DEF_CMD("txcsum", IFCAP_TXCSUM, setifcap),
1783 DEF_CMD("-txcsum", -IFCAP_TXCSUM, setifcap),
1784 DEF_CMD("netcons", IFCAP_NETCONS, setifcap),
1785 DEF_CMD("-netcons", -IFCAP_NETCONS, setifcap),
1786 DEF_CMD_ARG("pcp", setifpcp),
1787 DEF_CMD("-pcp", 0, disableifpcp),
1788 DEF_CMD("polling", IFCAP_POLLING, setifcap),
1789 DEF_CMD("-polling", -IFCAP_POLLING, setifcap),
1790 DEF_CMD("tso6", IFCAP_TSO6, setifcap),
1791 DEF_CMD("-tso6", -IFCAP_TSO6, setifcap),
1792 DEF_CMD("tso4", IFCAP_TSO4, setifcap),
1793 DEF_CMD("-tso4", -IFCAP_TSO4, setifcap),
1794 DEF_CMD("tso", IFCAP_TSO, setifcap),
1795 DEF_CMD("-tso", -IFCAP_TSO, setifcap),
1796 DEF_CMD("toe", IFCAP_TOE, setifcap),
1797 DEF_CMD("-toe", -IFCAP_TOE, setifcap),
1798 DEF_CMD("lro", IFCAP_LRO, setifcap),
1799 DEF_CMD("-lro", -IFCAP_LRO, setifcap),
1800 DEF_CMD("txtls", IFCAP_TXTLS, setifcap),
1801 DEF_CMD("-txtls", -IFCAP_TXTLS, setifcap),
1802 DEF_CMD_SARG("rxtls", IFCAP2_RXTLS4_NAME "," IFCAP2_RXTLS6_NAME,
1804 DEF_CMD_SARG("-rxtls", "-"IFCAP2_RXTLS4_NAME ",-" IFCAP2_RXTLS6_NAME,
1806 DEF_CMD("wol", IFCAP_WOL, setifcap),
1807 DEF_CMD("-wol", -IFCAP_WOL, setifcap),
1808 DEF_CMD("wol_ucast", IFCAP_WOL_UCAST, setifcap),
1809 DEF_CMD("-wol_ucast", -IFCAP_WOL_UCAST, setifcap),
1810 DEF_CMD("wol_mcast", IFCAP_WOL_MCAST, setifcap),
1811 DEF_CMD("-wol_mcast", -IFCAP_WOL_MCAST, setifcap),
1812 DEF_CMD("wol_magic", IFCAP_WOL_MAGIC, setifcap),
1813 DEF_CMD("-wol_magic", -IFCAP_WOL_MAGIC, setifcap),
1814 DEF_CMD("txrtlmt", IFCAP_TXRTLMT, setifcap),
1815 DEF_CMD("-txrtlmt", -IFCAP_TXRTLMT, setifcap),
1816 DEF_CMD("txtlsrtlmt", IFCAP_TXTLS_RTLMT, setifcap),
1817 DEF_CMD("-txtlsrtlmt", -IFCAP_TXTLS_RTLMT, setifcap),
1818 DEF_CMD("hwrxtstmp", IFCAP_HWRXTSTMP, setifcap),
1819 DEF_CMD("-hwrxtstmp", -IFCAP_HWRXTSTMP, setifcap),
1820 DEF_CMD("normal", -IFF_LINK0, setifflags),
1821 DEF_CMD("compress", IFF_LINK0, setifflags),
1822 DEF_CMD("noicmp", IFF_LINK1, setifflags),
1823 DEF_CMD_ARG("mtu", setifmtu),
1824 DEF_CMD_ARG("name", setifname),
1827 static __constructor void
1832 for (i = 0; i < nitems(basic_cmds); i++)
1833 cmd_register(&basic_cmds[i]);