blob: bad2017feb587c9281d8590ccea0837b5b6bbee3 [file] [log] [blame]
"Robert P. J. Day"63fc1a92006-07-02 19:47:05 +00001/* vi: set sw=4 ts=4: */
Glenn L McGrath9a2d2722002-11-10 01:33:55 +00002/*
Denis Vlasenkoe1a0d482006-10-20 13:28:22 +00003 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
Glenn L McGrath9a2d2722002-11-10 01:33:55 +00004 *
Denys Vlasenko0ef64bd2010-08-16 20:14:46 +02005 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
Glenn L McGrath9a2d2722002-11-10 01:33:55 +00006 */
Eric Andersenab4e19a2003-01-14 08:54:08 +00007#include <net/if.h>
8#include <net/if_packet.h>
9#include <netpacket/packet.h>
Denys Vlasenkob307eab2011-06-12 17:15:16 +020010#include <netinet/if_ether.h>
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000011
Denis Vlasenko9a7d38f2007-05-31 22:42:12 +000012#include "ip_common.h" /* #include "libbb.h" is inside */
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000013#include "rt_names.h"
14#include "utils.h"
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000015
Denys Vlasenkob276e412010-08-22 10:02:55 +020016#ifndef IFLA_LINKINFO
17# define IFLA_LINKINFO 18
Denys Vlasenkoc71ec702010-08-30 19:20:09 +020018# define IFLA_INFO_KIND 1
Denys Vlasenkob276e412010-08-22 10:02:55 +020019#endif
Denys Vlasenkoc71ec702010-08-30 19:20:09 +020020
Denis Vlasenko540a2a12007-04-07 01:14:45 +000021/* taken from linux/sockios.h */
Denys Vlasenkoe4dcba12010-10-28 18:57:19 +020022#define SIOCSIFNAME 0x8923 /* set interface name */
Eric Andersenab4e19a2003-01-14 08:54:08 +000023
Denis Vlasenko540a2a12007-04-07 01:14:45 +000024/* Exits on error */
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000025static int get_ctl_fd(void)
26{
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000027 int fd;
28
29 fd = socket(PF_INET, SOCK_DGRAM, 0);
30 if (fd >= 0)
31 return fd;
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000032 fd = socket(PF_PACKET, SOCK_DGRAM, 0);
33 if (fd >= 0)
34 return fd;
Bernhard Reutner-Fischerb2908892007-04-12 11:34:39 +000035 return xsocket(PF_INET6, SOCK_DGRAM, 0);
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000036}
37
Denis Vlasenko540a2a12007-04-07 01:14:45 +000038/* Exits on error */
39static void do_chflags(char *dev, uint32_t flags, uint32_t mask)
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000040{
41 struct ifreq ifr;
42 int fd;
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000043
Denis Vlasenko360d9662008-12-02 18:18:50 +000044 strncpy_IFNAMSIZ(ifr.ifr_name, dev);
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000045 fd = get_ctl_fd();
Denis Vlasenkofb79a2e2007-07-14 22:07:14 +000046 xioctl(fd, SIOCGIFFLAGS, &ifr);
Denis Vlasenko540a2a12007-04-07 01:14:45 +000047 if ((ifr.ifr_flags ^ flags) & mask) {
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000048 ifr.ifr_flags &= ~mask;
Denis Vlasenko540a2a12007-04-07 01:14:45 +000049 ifr.ifr_flags |= mask & flags;
Denis Vlasenkofb79a2e2007-07-14 22:07:14 +000050 xioctl(fd, SIOCSIFFLAGS, &ifr);
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000051 }
52 close(fd);
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000053}
54
Denis Vlasenko540a2a12007-04-07 01:14:45 +000055/* Exits on error */
56static void do_changename(char *dev, char *newdev)
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000057{
58 struct ifreq ifr;
59 int fd;
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000060
Denis Vlasenko360d9662008-12-02 18:18:50 +000061 strncpy_IFNAMSIZ(ifr.ifr_name, dev);
62 strncpy_IFNAMSIZ(ifr.ifr_newname, newdev);
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000063 fd = get_ctl_fd();
Denis Vlasenkofb79a2e2007-07-14 22:07:14 +000064 xioctl(fd, SIOCSIFNAME, &ifr);
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000065 close(fd);
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000066}
67
Denis Vlasenko540a2a12007-04-07 01:14:45 +000068/* Exits on error */
69static void set_qlen(char *dev, int qlen)
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000070{
71 struct ifreq ifr;
72 int s;
73
74 s = get_ctl_fd();
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000075 memset(&ifr, 0, sizeof(ifr));
Denis Vlasenko360d9662008-12-02 18:18:50 +000076 strncpy_IFNAMSIZ(ifr.ifr_name, dev);
Eric Andersenc7bda1c2004-03-15 08:29:22 +000077 ifr.ifr_qlen = qlen;
Denis Vlasenkofb79a2e2007-07-14 22:07:14 +000078 xioctl(s, SIOCSIFTXQLEN, &ifr);
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000079 close(s);
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000080}
81
Denis Vlasenko540a2a12007-04-07 01:14:45 +000082/* Exits on error */
83static void set_mtu(char *dev, int mtu)
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000084{
85 struct ifreq ifr;
86 int s;
87
88 s = get_ctl_fd();
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000089 memset(&ifr, 0, sizeof(ifr));
Denis Vlasenko360d9662008-12-02 18:18:50 +000090 strncpy_IFNAMSIZ(ifr.ifr_name, dev);
Eric Andersenc7bda1c2004-03-15 08:29:22 +000091 ifr.ifr_mtu = mtu;
Denis Vlasenkofb79a2e2007-07-14 22:07:14 +000092 xioctl(s, SIOCSIFMTU, &ifr);
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000093 close(s);
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000094}
95
Denis Vlasenko540a2a12007-04-07 01:14:45 +000096/* Exits on error */
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000097static int get_address(char *dev, int *htype)
98{
99 struct ifreq ifr;
100 struct sockaddr_ll me;
Eric Andersend78aea82006-01-30 18:00:02 +0000101 socklen_t alen;
Glenn L McGrath9a2d2722002-11-10 01:33:55 +0000102 int s;
103
Bernhard Reutner-Fischerb2908892007-04-12 11:34:39 +0000104 s = xsocket(PF_PACKET, SOCK_DGRAM, 0);
Glenn L McGrath9a2d2722002-11-10 01:33:55 +0000105
106 memset(&ifr, 0, sizeof(ifr));
Denis Vlasenko360d9662008-12-02 18:18:50 +0000107 strncpy_IFNAMSIZ(ifr.ifr_name, dev);
Denis Vlasenkofb79a2e2007-07-14 22:07:14 +0000108 xioctl(s, SIOCGIFINDEX, &ifr);
Glenn L McGrath9a2d2722002-11-10 01:33:55 +0000109
110 memset(&me, 0, sizeof(me));
111 me.sll_family = AF_PACKET;
112 me.sll_ifindex = ifr.ifr_ifindex;
113 me.sll_protocol = htons(ETH_P_LOOP);
Bernhard Reutner-Fischerb2908892007-04-12 11:34:39 +0000114 xbind(s, (struct sockaddr*)&me, sizeof(me));
Glenn L McGrath9a2d2722002-11-10 01:33:55 +0000115 alen = sizeof(me);
Denis Vlasenkoa771e7c2009-04-21 23:48:38 +0000116 getsockname(s, (struct sockaddr*)&me, &alen);
117 //never happens:
118 //if (getsockname(s, (struct sockaddr*)&me, &alen) == -1)
119 // bb_perror_msg_and_die("getsockname");
Glenn L McGrath9a2d2722002-11-10 01:33:55 +0000120 close(s);
121 *htype = me.sll_hatype;
122 return me.sll_halen;
123}
124
Denis Vlasenko540a2a12007-04-07 01:14:45 +0000125/* Exits on error */
126static void parse_address(char *dev, int hatype, int halen, char *lla, struct ifreq *ifr)
Glenn L McGrath9a2d2722002-11-10 01:33:55 +0000127{
128 int alen;
129
130 memset(ifr, 0, sizeof(*ifr));
Denis Vlasenko360d9662008-12-02 18:18:50 +0000131 strncpy_IFNAMSIZ(ifr->ifr_name, dev);
Glenn L McGrath9a2d2722002-11-10 01:33:55 +0000132 ifr->ifr_hwaddr.sa_family = hatype;
Bernhard Reutner-Fischer51a06c02008-05-16 17:19:03 +0000133
134 alen = hatype == 1/*ARPHRD_ETHER*/ ? 14/*ETH_HLEN*/ : 19/*INFINIBAND_HLEN*/;
135 alen = ll_addr_a2n((unsigned char *)(ifr->ifr_hwaddr.sa_data), alen, lla);
Glenn L McGrath9a2d2722002-11-10 01:33:55 +0000136 if (alen < 0)
Bernhard Reutner-Fischer51a06c02008-05-16 17:19:03 +0000137 exit(EXIT_FAILURE);
Glenn L McGrath9a2d2722002-11-10 01:33:55 +0000138 if (alen != halen) {
Denis Vlasenko540a2a12007-04-07 01:14:45 +0000139 bb_error_msg_and_die("wrong address (%s) length: expected %d bytes", lla, halen);
Glenn L McGrath9a2d2722002-11-10 01:33:55 +0000140 }
Glenn L McGrath9a2d2722002-11-10 01:33:55 +0000141}
142
Denis Vlasenko540a2a12007-04-07 01:14:45 +0000143/* Exits on error */
144static void set_address(struct ifreq *ifr, int brd)
Glenn L McGrath9a2d2722002-11-10 01:33:55 +0000145{
146 int s;
147
148 s = get_ctl_fd();
Denis Vlasenkofb79a2e2007-07-14 22:07:14 +0000149 if (brd)
150 xioctl(s, SIOCSIFHWBROADCAST, ifr);
151 else
152 xioctl(s, SIOCSIFHWADDR, ifr);
Glenn L McGrath9a2d2722002-11-10 01:33:55 +0000153 close(s);
Glenn L McGrath9a2d2722002-11-10 01:33:55 +0000154}
155
156
Denis Vlasenkoa60f84e2008-07-05 09:18:54 +0000157static void die_must_be_on_off(const char *msg) NORETURN;
Denis Vlasenkoed6a49c2007-11-18 22:56:25 +0000158static void die_must_be_on_off(const char *msg)
159{
160 bb_error_msg_and_die("argument of \"%s\" must be \"on\" or \"off\"", msg);
161}
162
Denis Vlasenko540a2a12007-04-07 01:14:45 +0000163/* Return value becomes exitcode. It's okay to not return at all */
Denis Vlasenkoed6a49c2007-11-18 22:56:25 +0000164static int do_set(char **argv)
Glenn L McGrath9a2d2722002-11-10 01:33:55 +0000165{
166 char *dev = NULL;
Denis Vlasenko98ee06d2006-12-31 18:57:37 +0000167 uint32_t mask = 0;
168 uint32_t flags = 0;
Glenn L McGrath9a2d2722002-11-10 01:33:55 +0000169 int qlen = -1;
170 int mtu = -1;
171 char *newaddr = NULL;
172 char *newbrd = NULL;
173 struct ifreq ifr0, ifr1;
174 char *newname = NULL;
175 int htype, halen;
Denis Vlasenko6ca409e2007-08-12 20:58:27 +0000176 static const char keywords[] ALIGN1 =
Bernhard Reutner-Fischerab0e4122010-05-25 16:57:08 +0200177 "up\0""down\0""name\0""mtu\0""qlen\0""multicast\0"
Denis Vlasenko44d5dce2008-11-01 00:10:51 +0000178 "arp\0""address\0""dev\0";
Bernhard Reutner-Fischerab0e4122010-05-25 16:57:08 +0200179 enum { ARG_up = 0, ARG_down, ARG_name, ARG_mtu, ARG_qlen, ARG_multicast,
Denis Vlasenko44d5dce2008-11-01 00:10:51 +0000180 ARG_arp, ARG_addr, ARG_dev };
Denis Vlasenkoed6a49c2007-11-18 22:56:25 +0000181 static const char str_on_off[] ALIGN1 = "on\0""off\0";
182 enum { PARM_on = 0, PARM_off };
Bernhard Reutner-Fischerb2908892007-04-12 11:34:39 +0000183 smalluint key;
Glenn L McGrath9a2d2722002-11-10 01:33:55 +0000184
Denis Vlasenkoed6a49c2007-11-18 22:56:25 +0000185 while (*argv) {
Denis Vlasenko44d5dce2008-11-01 00:10:51 +0000186 /* substring search ensures that e.g. "addr" and "address"
187 * are both accepted */
188 key = index_in_substrings(keywords, *argv);
Bernhard Reutner-Fischerb2908892007-04-12 11:34:39 +0000189 if (key == ARG_up) {
Glenn L McGrath9a2d2722002-11-10 01:33:55 +0000190 mask |= IFF_UP;
191 flags |= IFF_UP;
Bernhard Reutner-Fischerd148e482010-05-25 16:16:28 +0200192 } else if (key == ARG_down) {
Glenn L McGrath9a2d2722002-11-10 01:33:55 +0000193 mask |= IFF_UP;
194 flags &= ~IFF_UP;
Bernhard Reutner-Fischerd148e482010-05-25 16:16:28 +0200195 } else if (key == ARG_name) {
Glenn L McGrath9a2d2722002-11-10 01:33:55 +0000196 NEXT_ARG();
197 newname = *argv;
Bernhard Reutner-Fischerd148e482010-05-25 16:16:28 +0200198 } else if (key == ARG_mtu) {
Glenn L McGrath9a2d2722002-11-10 01:33:55 +0000199 NEXT_ARG();
200 if (mtu != -1)
201 duparg("mtu", *argv);
Denis Vlasenko76140a72009-03-05 09:21:57 +0000202 mtu = get_unsigned(*argv, "mtu");
Bernhard Reutner-Fischerab0e4122010-05-25 16:57:08 +0200203 } else if (key == ARG_qlen) {
204 NEXT_ARG();
205 if (qlen != -1)
206 duparg("qlen", *argv);
207 qlen = get_unsigned(*argv, "qlen");
Bernhard Reutner-Fischerd148e482010-05-25 16:16:28 +0200208 } else if (key == ARG_addr) {
Rob Landley483027f2005-12-15 05:29:48 +0000209 NEXT_ARG();
210 newaddr = *argv;
Bernhard Reutner-Fischerd148e482010-05-25 16:16:28 +0200211 } else if (key >= ARG_dev) {
Bernhard Reutner-Fischerb2908892007-04-12 11:34:39 +0000212 if (key == ARG_dev) {
Glenn L McGrath9a2d2722002-11-10 01:33:55 +0000213 NEXT_ARG();
214 }
215 if (dev)
216 duparg2("dev", *argv);
217 dev = *argv;
Bernhard Reutner-Fischerd148e482010-05-25 16:16:28 +0200218 } else {
219 int param;
220 NEXT_ARG();
221 param = index_in_strings(str_on_off, *argv);
222 if (key == ARG_multicast) {
223 if (param < 0)
224 die_must_be_on_off("multicast");
225 mask |= IFF_MULTICAST;
226 if (param == PARM_on)
227 flags |= IFF_MULTICAST;
228 else
229 flags &= ~IFF_MULTICAST;
230 } else if (key == ARG_arp) {
231 if (param < 0)
232 die_must_be_on_off("arp");
233 mask |= IFF_NOARP;
234 if (param == PARM_on)
235 flags &= ~IFF_NOARP;
236 else
237 flags |= IFF_NOARP;
238 }
Glenn L McGrath9a2d2722002-11-10 01:33:55 +0000239 }
Denis Vlasenkoed6a49c2007-11-18 22:56:25 +0000240 argv++;
Glenn L McGrath9a2d2722002-11-10 01:33:55 +0000241 }
242
243 if (!dev) {
Denis Vlasenko540a2a12007-04-07 01:14:45 +0000244 bb_error_msg_and_die(bb_msg_requires_arg, "\"dev\"");
Glenn L McGrath9a2d2722002-11-10 01:33:55 +0000245 }
246
247 if (newaddr || newbrd) {
248 halen = get_address(dev, &htype);
Glenn L McGrath9a2d2722002-11-10 01:33:55 +0000249 if (newaddr) {
Denis Vlasenko540a2a12007-04-07 01:14:45 +0000250 parse_address(dev, htype, halen, newaddr, &ifr0);
Bernhard Reutner-Fischerd148e482010-05-25 16:16:28 +0200251 set_address(&ifr0, 0);
Glenn L McGrath9a2d2722002-11-10 01:33:55 +0000252 }
253 if (newbrd) {
Denis Vlasenko540a2a12007-04-07 01:14:45 +0000254 parse_address(dev, htype, halen, newbrd, &ifr1);
Bernhard Reutner-Fischerd148e482010-05-25 16:16:28 +0200255 set_address(&ifr1, 1);
Glenn L McGrath9a2d2722002-11-10 01:33:55 +0000256 }
257 }
258
259 if (newname && strcmp(dev, newname)) {
Denis Vlasenko540a2a12007-04-07 01:14:45 +0000260 do_changename(dev, newname);
Glenn L McGrath9a2d2722002-11-10 01:33:55 +0000261 dev = newname;
262 }
Eric Andersenc7bda1c2004-03-15 08:29:22 +0000263 if (qlen != -1) {
Denis Vlasenko540a2a12007-04-07 01:14:45 +0000264 set_qlen(dev, qlen);
Glenn L McGrath9a2d2722002-11-10 01:33:55 +0000265 }
Eric Andersenc7bda1c2004-03-15 08:29:22 +0000266 if (mtu != -1) {
Denis Vlasenko540a2a12007-04-07 01:14:45 +0000267 set_mtu(dev, mtu);
Glenn L McGrath9a2d2722002-11-10 01:33:55 +0000268 }
Glenn L McGrath9a2d2722002-11-10 01:33:55 +0000269 if (mask)
Denis Vlasenko540a2a12007-04-07 01:14:45 +0000270 do_chflags(dev, flags, mask);
Glenn L McGrath9a2d2722002-11-10 01:33:55 +0000271 return 0;
272}
273
Denis Vlasenkoed6a49c2007-11-18 22:56:25 +0000274static int ipaddr_list_link(char **argv)
Glenn L McGrath2626ef62002-12-02 01:40:05 +0000275{
276 preferred_family = AF_PACKET;
Denis Vlasenkoed6a49c2007-11-18 22:56:25 +0000277 return ipaddr_list_or_flush(argv, 0);
Glenn L McGrath2626ef62002-12-02 01:40:05 +0000278}
279
Bernhard Reutner-Fischer6faebfa2010-05-25 10:34:27 +0200280#ifndef NLMSG_TAIL
281#define NLMSG_TAIL(nmsg) \
282 ((struct rtattr *) (((void *) (nmsg)) + NLMSG_ALIGN((nmsg)->nlmsg_len)))
283#endif
284/* Return value becomes exitcode. It's okay to not return at all */
285static int do_change(char **argv, const unsigned rtm)
286{
287 static const char keywords[] ALIGN1 =
288 "link\0""name\0""type\0""dev\0";
289 enum {
290 ARG_link,
291 ARG_name,
292 ARG_type,
293 ARG_dev,
294 };
295 struct rtnl_handle rth;
296 struct {
Denys Vlasenkofb132e42010-10-29 11:46:52 +0200297 struct nlmsghdr n;
298 struct ifinfomsg i;
299 char buf[1024];
Bernhard Reutner-Fischer6faebfa2010-05-25 10:34:27 +0200300 } req;
Bernhard Reutner-Fischerd148e482010-05-25 16:16:28 +0200301 smalluint arg;
Bernhard Reutner-Fischer6faebfa2010-05-25 10:34:27 +0200302 char *name_str = NULL, *link_str = NULL, *type_str = NULL, *dev_str = NULL;
303
304 memset(&req, 0, sizeof(req));
305
306 req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg));
307 req.n.nlmsg_flags = NLM_F_REQUEST;
308 req.n.nlmsg_type = rtm;
309 req.i.ifi_family = preferred_family;
310 if (rtm == RTM_NEWLINK)
311 req.n.nlmsg_flags |= NLM_F_CREATE|NLM_F_EXCL;
312
313 while (*argv) {
314 arg = index_in_substrings(keywords, *argv);
315 if (arg == ARG_link) {
316 NEXT_ARG();
317 link_str = *argv;
318 } else if (arg == ARG_name) {
319 NEXT_ARG();
320 name_str = *argv;
321 } else if (arg == ARG_type) {
322 NEXT_ARG();
323 type_str = *argv;
324 } else {
325 if (arg == ARG_dev) {
326 if (dev_str)
327 duparg(*argv, "dev");
328 NEXT_ARG();
329 }
330 dev_str = *argv;
331 }
332 argv++;
333 }
334 xrtnl_open(&rth);
335 ll_init_map(&rth);
336 if (type_str) {
337 struct rtattr *linkinfo = NLMSG_TAIL(&req.n);
338
339 addattr_l(&req.n, sizeof(req), IFLA_LINKINFO, NULL, 0);
340 addattr_l(&req.n, sizeof(req), IFLA_INFO_KIND, type_str,
341 strlen(type_str));
342 linkinfo->rta_len = (void *)NLMSG_TAIL(&req.n) - (void *)linkinfo;
343 }
344 if (rtm != RTM_NEWLINK) {
345 if (!dev_str)
346 return 1; /* Need a device to delete */
347 req.i.ifi_index = xll_name_to_index(dev_str);
348 } else {
349 if (!name_str)
350 name_str = dev_str;
351 if (link_str) {
352 int idx = xll_name_to_index(link_str);
353 addattr_l(&req.n, sizeof(req), IFLA_LINK, &idx, 4);
354 }
355 }
356 if (name_str) {
357 const size_t name_len = strlen(name_str) + 1;
358 if (name_len < 2 || name_len > IFNAMSIZ)
359 invarg(name_str, "name");
360 addattr_l(&req.n, sizeof(req), IFLA_IFNAME, name_str, name_len);
361 }
362 if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0)
363 return 2;
364 return 0;
365}
366
Denis Vlasenko540a2a12007-04-07 01:14:45 +0000367/* Return value becomes exitcode. It's okay to not return at all */
Denys Vlasenko2e9b5512010-07-24 23:27:38 +0200368int FAST_FUNC do_iplink(char **argv)
Glenn L McGrath9a2d2722002-11-10 01:33:55 +0000369{
Denis Vlasenko6ca409e2007-08-12 20:58:27 +0000370 static const char keywords[] ALIGN1 =
Bernhard Reutner-Fischer6faebfa2010-05-25 10:34:27 +0200371 "add\0""delete\0""set\0""show\0""lst\0""list\0";
Bernhard Reutner-Fischerd148e482010-05-25 16:16:28 +0200372 if (*argv) {
373 smalluint key = index_in_substrings(keywords, *argv);
374 if (key > 5) /* invalid argument */
375 bb_error_msg_and_die(bb_msg_invalid_arg, *argv, applet_name);
376 argv++;
377 if (key <= 1) /* add/delete */
378 return do_change(argv, key ? RTM_DELLINK : RTM_NEWLINK);
379 else if (key == 2) /* set */
380 return do_set(argv);
381 }
Denis Vlasenkoed6a49c2007-11-18 22:56:25 +0000382 /* show, lst, list */
383 return ipaddr_list_link(argv);
Glenn L McGrath9a2d2722002-11-10 01:33:55 +0000384}