ifenslave.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  1. /* Mode: C;
  2. *
  3. * Mini ifenslave implementation for busybox
  4. * Copyright (C) 2005 by Marc Leeman <marc.leeman@barco.com>
  5. *
  6. * ifenslave.c: Configure network interfaces for parallel routing.
  7. *
  8. * This program controls the Linux implementation of running multiple
  9. * network interfaces in parallel.
  10. *
  11. * Author: Donald Becker <becker@cesdis.gsfc.nasa.gov>
  12. * Copyright 1994-1996 Donald Becker
  13. *
  14. * This program is free software; you can redistribute it
  15. * and/or modify it under the terms of the GNU General Public
  16. * License as published by the Free Software Foundation.
  17. *
  18. * The author may be reached as becker@CESDIS.gsfc.nasa.gov, or C/O
  19. * Center of Excellence in Space Data and Information Sciences
  20. * Code 930.5, Goddard Space Flight Center, Greenbelt MD 20771
  21. *
  22. * Changes :
  23. * - 2000/10/02 Willy Tarreau <willy at meta-x.org> :
  24. * - few fixes. Master's MAC address is now correctly taken from
  25. * the first device when not previously set ;
  26. * - detach support : call BOND_RELEASE to detach an enslaved interface.
  27. * - give a mini-howto from command-line help : # ifenslave -h
  28. *
  29. * - 2001/02/16 Chad N. Tindel <ctindel at ieee dot org> :
  30. * - Master is now brought down before setting the MAC address. In
  31. * the 2.4 kernel you can't change the MAC address while the device is
  32. * up because you get EBUSY.
  33. *
  34. * - 2001/09/13 Takao Indoh <indou dot takao at jp dot fujitsu dot com>
  35. * - Added the ability to change the active interface on a mode 1 bond
  36. * at runtime.
  37. *
  38. * - 2001/10/23 Chad N. Tindel <ctindel at ieee dot org> :
  39. * - No longer set the MAC address of the master. The bond device will
  40. * take care of this itself
  41. * - Try the SIOC*** versions of the bonding ioctls before using the
  42. * old versions
  43. * - 2002/02/18 Erik Habbinga <erik_habbinga @ hp dot com> :
  44. * - ifr2.ifr_flags was not initialized in the hwaddr_notset case,
  45. * SIOCGIFFLAGS now called before hwaddr_notset test
  46. *
  47. * - 2002/10/31 Tony Cureington <tony.cureington * hp_com> :
  48. * - If the master does not have a hardware address when the first slave
  49. * is enslaved, the master is assigned the hardware address of that
  50. * slave - there is a comment in bonding.c stating "ifenslave takes
  51. * care of this now." This corrects the problem of slaves having
  52. * different hardware addresses in active-backup mode when
  53. * multiple interfaces are specified on a single ifenslave command
  54. * (ifenslave bond0 eth0 eth1).
  55. *
  56. * - 2003/03/18 - Tsippy Mendelson <tsippy.mendelson at intel dot com> and
  57. * Shmulik Hen <shmulik.hen at intel dot com>
  58. * - Moved setting the slave's mac address and openning it, from
  59. * the application to the driver. This enables support of modes
  60. * that need to use the unique mac address of each slave.
  61. * The driver also takes care of closing the slave and restoring its
  62. * original mac address upon release.
  63. * In addition, block possibility of enslaving before the master is up.
  64. * This prevents putting the system in an undefined state.
  65. *
  66. * - 2003/05/01 - Amir Noam <amir.noam at intel dot com>
  67. * - Added ABI version control to restore compatibility between
  68. * new/old ifenslave and new/old bonding.
  69. * - Prevent adding an adapter that is already a slave.
  70. * Fixes the problem of stalling the transmission and leaving
  71. * the slave in a down state.
  72. *
  73. * - 2003/05/01 - Shmulik Hen <shmulik.hen at intel dot com>
  74. * - Prevent enslaving if the bond device is down.
  75. * Fixes the problem of leaving the system in unstable state and
  76. * halting when trying to remove the module.
  77. * - Close socket on all abnormal exists.
  78. * - Add versioning scheme that follows that of the bonding driver.
  79. * current version is 1.0.0 as a base line.
  80. *
  81. * - 2003/05/22 - Jay Vosburgh <fubar at us dot ibm dot com>
  82. * - ifenslave -c was broken; it's now fixed
  83. * - Fixed problem with routes vanishing from master during enslave
  84. * processing.
  85. *
  86. * - 2003/05/27 - Amir Noam <amir.noam at intel dot com>
  87. * - Fix backward compatibility issues:
  88. * For drivers not using ABI versions, slave was set down while
  89. * it should be left up before enslaving.
  90. * Also, master was not set down and the default set_mac_address()
  91. * would fail and generate an error message in the system log.
  92. * - For opt_c: slave should not be set to the master's setting
  93. * while it is running. It was already set during enslave. To
  94. * simplify things, it is now handeled separately.
  95. *
  96. * - 2003/12/01 - Shmulik Hen <shmulik.hen at intel dot com>
  97. * - Code cleanup and style changes
  98. * set version to 1.1.0
  99. */
  100. #include "libbb.h"
  101. #include <net/if_arp.h>
  102. #include <linux/if_bonding.h>
  103. #include <linux/sockios.h>
  104. typedef unsigned long long u64; /* hack, so we may include kernel's ethtool.h */
  105. typedef uint32_t u32; /* ditto */
  106. typedef uint16_t u16; /* ditto */
  107. typedef uint8_t u8; /* ditto */
  108. #include <linux/ethtool.h>
  109. struct dev_data {
  110. struct ifreq mtu, flags, hwaddr;
  111. };
  112. enum { skfd = 3 }; /* AF_INET socket for ioctl() calls.*/
  113. struct globals {
  114. unsigned abi_ver; /* userland - kernel ABI version */
  115. smallint hwaddr_set; /* Master's hwaddr is set */
  116. struct dev_data master;
  117. struct dev_data slave;
  118. };
  119. #define G (*ptr_to_globals)
  120. #define abi_ver (G.abi_ver )
  121. #define hwaddr_set (G.hwaddr_set)
  122. #define master (G.master )
  123. #define slave (G.slave )
  124. #define INIT_G() do { \
  125. SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
  126. } while (0)
  127. static void get_drv_info(char *master_ifname);
  128. static int get_if_settings(char *ifname, struct dev_data *dd);
  129. static int get_slave_flags(char *slave_ifname);
  130. static int set_master_hwaddr(char *master_ifname, struct sockaddr *hwaddr);
  131. static int set_slave_hwaddr(char *slave_ifname, struct sockaddr *hwaddr);
  132. static int set_slave_mtu(char *slave_ifname, int mtu);
  133. static int set_if_flags(char *ifname, short flags);
  134. static int set_if_up(char *ifname, short flags);
  135. static int set_if_down(char *ifname, short flags);
  136. static int clear_if_addr(char *ifname);
  137. static int set_if_addr(char *master_ifname, char *slave_ifname);
  138. static void change_active(char *master_ifname, char *slave_ifname);
  139. static int enslave(char *master_ifname, char *slave_ifname);
  140. static int release(char *master_ifname, char *slave_ifname);
  141. int ifenslave_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
  142. int ifenslave_main(int argc ATTRIBUTE_UNUSED, char **argv)
  143. {
  144. char *master_ifname, *slave_ifname;
  145. int rv;
  146. int res;
  147. unsigned opt;
  148. enum {
  149. OPT_c = (1 << 0),
  150. OPT_d = (1 << 1),
  151. OPT_f = (1 << 2),
  152. };
  153. #if ENABLE_GETOPT_LONG
  154. static const char ifenslave_longopts[] ALIGN1 =
  155. "change-active" No_argument "c"
  156. "detach" No_argument "d"
  157. "force" No_argument "f"
  158. ;
  159. applet_long_options = ifenslave_longopts;
  160. #endif
  161. opt = getopt32(argv, "cdf");
  162. argv += optind;
  163. if (opt & (opt-1)) /* options check */
  164. bb_show_usage();
  165. /* Copy the interface name */
  166. master_ifname = *argv++;
  167. /* No remaining args means show all interfaces. */
  168. if (!master_ifname) {
  169. display_interfaces(NULL);
  170. return EXIT_SUCCESS;
  171. }
  172. /* Open a basic socket */
  173. xmove_fd(xsocket(AF_INET, SOCK_DGRAM, 0), skfd);
  174. /* exchange abi version with bonding module */
  175. get_drv_info(master_ifname);
  176. slave_ifname = *argv++;
  177. if (!slave_ifname) {
  178. if (opt & (OPT_d|OPT_c)) {
  179. display_interfaces(slave_ifname);
  180. return 2; /* why? */
  181. }
  182. /* A single arg means show the
  183. * configuration for this interface
  184. */
  185. display_interfaces(master_ifname);
  186. return EXIT_SUCCESS;
  187. }
  188. res = get_if_settings(master_ifname, &master);
  189. if (res) {
  190. /* Probably a good reason not to go on */
  191. bb_perror_msg_and_die("%s: can't get settings", master_ifname);
  192. }
  193. /* check if master is indeed a master;
  194. * if not then fail any operation
  195. */
  196. if (!(master.flags.ifr_flags & IFF_MASTER))
  197. bb_error_msg_and_die("%s is not a master", master_ifname);
  198. /* check if master is up; if not then fail any operation */
  199. if (!(master.flags.ifr_flags & IFF_UP))
  200. bb_error_msg_and_die("%s is not up", master_ifname);
  201. /* Only for enslaving */
  202. if (!(opt & (OPT_c|OPT_d))) {
  203. sa_family_t master_family = master.hwaddr.ifr_hwaddr.sa_family;
  204. /* The family '1' is ARPHRD_ETHER for ethernet. */
  205. if (master_family != 1 && !(opt & OPT_f)) {
  206. bb_error_msg_and_die(
  207. "%s is not ethernet-like (-f overrides)",
  208. master_ifname);
  209. }
  210. }
  211. /* Accepts only one slave */
  212. if (opt & OPT_c) {
  213. /* change active slave */
  214. res = get_slave_flags(slave_ifname);
  215. if (res) {
  216. bb_perror_msg_and_die(
  217. "%s: can't get flags", slave_ifname);
  218. }
  219. change_active(master_ifname, slave_ifname);
  220. return EXIT_SUCCESS;
  221. }
  222. /* Accept multiple slaves */
  223. res = 0;
  224. do {
  225. if (opt & OPT_d) {
  226. /* detach a slave interface from the master */
  227. rv = get_slave_flags(slave_ifname);
  228. if (rv) {
  229. /* Can't work with this slave. */
  230. /* remember the error and skip it*/
  231. bb_perror_msg(
  232. "skipping %s: can't get flags",
  233. slave_ifname);
  234. res = rv;
  235. continue;
  236. }
  237. rv = release(master_ifname, slave_ifname);
  238. if (rv) {
  239. bb_perror_msg(
  240. "master %s, slave %s: "
  241. "can't release",
  242. master_ifname, slave_ifname);
  243. res = rv;
  244. }
  245. } else {
  246. /* attach a slave interface to the master */
  247. rv = get_if_settings(slave_ifname, &slave);
  248. if (rv) {
  249. /* Can't work with this slave. */
  250. /* remember the error and skip it*/
  251. bb_perror_msg(
  252. "skipping %s: can't get settings",
  253. slave_ifname);
  254. res = rv;
  255. continue;
  256. }
  257. rv = enslave(master_ifname, slave_ifname);
  258. if (rv) {
  259. bb_perror_msg(
  260. "master %s, slave %s: "
  261. "can't enslave",
  262. master_ifname, slave_ifname);
  263. res = rv;
  264. }
  265. }
  266. } while ((slave_ifname = *argv++) != NULL);
  267. if (ENABLE_FEATURE_CLEAN_UP) {
  268. close(skfd);
  269. }
  270. return res;
  271. }
  272. static void get_drv_info(char *master_ifname)
  273. {
  274. struct ifreq ifr;
  275. struct ethtool_drvinfo info;
  276. memset(&ifr, 0, sizeof(ifr));
  277. strncpy(ifr.ifr_name, master_ifname, IFNAMSIZ);
  278. ifr.ifr_data = (caddr_t)&info;
  279. info.cmd = ETHTOOL_GDRVINFO;
  280. strncpy(info.driver, "ifenslave", 32);
  281. snprintf(info.fw_version, 32, "%d", BOND_ABI_VERSION);
  282. if (ioctl(skfd, SIOCETHTOOL, &ifr) < 0) {
  283. if (errno == EOPNOTSUPP)
  284. return;
  285. bb_perror_msg_and_die("%s: SIOCETHTOOL error", master_ifname);
  286. }
  287. abi_ver = bb_strtou(info.fw_version, NULL, 0);
  288. if (errno)
  289. bb_error_msg_and_die("%s: SIOCETHTOOL error", master_ifname);
  290. return;
  291. }
  292. static void change_active(char *master_ifname, char *slave_ifname)
  293. {
  294. struct ifreq ifr;
  295. if (!(slave.flags.ifr_flags & IFF_SLAVE)) {
  296. bb_error_msg_and_die(
  297. "%s is not a slave",
  298. slave_ifname);
  299. }
  300. strncpy(ifr.ifr_name, master_ifname, IFNAMSIZ);
  301. strncpy(ifr.ifr_slave, slave_ifname, IFNAMSIZ);
  302. if (ioctl(skfd, SIOCBONDCHANGEACTIVE, &ifr) < 0
  303. && ioctl(skfd, BOND_CHANGE_ACTIVE_OLD, &ifr) < 0
  304. ) {
  305. bb_perror_msg_and_die(
  306. "master %s, slave %s: can't "
  307. "change active",
  308. master_ifname, slave_ifname);
  309. }
  310. }
  311. static int enslave(char *master_ifname, char *slave_ifname)
  312. {
  313. struct ifreq ifr;
  314. int res;
  315. if (slave.flags.ifr_flags & IFF_SLAVE) {
  316. bb_error_msg(
  317. "%s is already a slave",
  318. slave_ifname);
  319. return 1;
  320. }
  321. res = set_if_down(slave_ifname, slave.flags.ifr_flags);
  322. if (res)
  323. return res;
  324. if (abi_ver < 2) {
  325. /* Older bonding versions would panic if the slave has no IP
  326. * address, so get the IP setting from the master.
  327. */
  328. res = set_if_addr(master_ifname, slave_ifname);
  329. if (res) {
  330. bb_perror_msg("%s: can't set address", slave_ifname);
  331. return res;
  332. }
  333. } else {
  334. res = clear_if_addr(slave_ifname);
  335. if (res) {
  336. bb_perror_msg("%s: can't clear address", slave_ifname);
  337. return res;
  338. }
  339. }
  340. if (master.mtu.ifr_mtu != slave.mtu.ifr_mtu) {
  341. res = set_slave_mtu(slave_ifname, master.mtu.ifr_mtu);
  342. if (res) {
  343. bb_perror_msg("%s: can't set MTU", slave_ifname);
  344. return res;
  345. }
  346. }
  347. if (hwaddr_set) {
  348. /* Master already has an hwaddr
  349. * so set it's hwaddr to the slave
  350. */
  351. if (abi_ver < 1) {
  352. /* The driver is using an old ABI, so
  353. * the application sets the slave's
  354. * hwaddr
  355. */
  356. res = set_slave_hwaddr(slave_ifname,
  357. &(master.hwaddr.ifr_hwaddr));
  358. if (res) {
  359. bb_perror_msg("%s: can't set hw address",
  360. slave_ifname);
  361. goto undo_mtu;
  362. }
  363. /* For old ABI the application needs to bring the
  364. * slave back up
  365. */
  366. res = set_if_up(slave_ifname, slave.flags.ifr_flags);
  367. if (res)
  368. goto undo_slave_mac;
  369. }
  370. /* The driver is using a new ABI,
  371. * so the driver takes care of setting
  372. * the slave's hwaddr and bringing
  373. * it up again
  374. */
  375. } else {
  376. /* No hwaddr for master yet, so
  377. * set the slave's hwaddr to it
  378. */
  379. if (abi_ver < 1) {
  380. /* For old ABI, the master needs to be
  381. * down before setting it's hwaddr
  382. */
  383. res = set_if_down(master_ifname, master.flags.ifr_flags);
  384. if (res)
  385. goto undo_mtu;
  386. }
  387. res = set_master_hwaddr(master_ifname,
  388. &(slave.hwaddr.ifr_hwaddr));
  389. if (res) {
  390. bb_error_msg("%s: can't set hw address",
  391. master_ifname);
  392. goto undo_mtu;
  393. }
  394. if (abi_ver < 1) {
  395. /* For old ABI, bring the master
  396. * back up
  397. */
  398. res = set_if_up(master_ifname, master.flags.ifr_flags);
  399. if (res)
  400. goto undo_master_mac;
  401. }
  402. hwaddr_set = 1;
  403. }
  404. /* Do the real thing */
  405. strncpy(ifr.ifr_name, master_ifname, IFNAMSIZ);
  406. strncpy(ifr.ifr_slave, slave_ifname, IFNAMSIZ);
  407. if (ioctl(skfd, SIOCBONDENSLAVE, &ifr) < 0
  408. && ioctl(skfd, BOND_ENSLAVE_OLD, &ifr) < 0
  409. ) {
  410. res = 1;
  411. }
  412. if (res)
  413. goto undo_master_mac;
  414. return 0;
  415. /* rollback (best effort) */
  416. undo_master_mac:
  417. set_master_hwaddr(master_ifname, &(master.hwaddr.ifr_hwaddr));
  418. hwaddr_set = 0;
  419. goto undo_mtu;
  420. undo_slave_mac:
  421. set_slave_hwaddr(slave_ifname, &(slave.hwaddr.ifr_hwaddr));
  422. undo_mtu:
  423. set_slave_mtu(slave_ifname, slave.mtu.ifr_mtu);
  424. return res;
  425. }
  426. static int release(char *master_ifname, char *slave_ifname)
  427. {
  428. struct ifreq ifr;
  429. int res = 0;
  430. if (!(slave.flags.ifr_flags & IFF_SLAVE)) {
  431. bb_error_msg("%s is not a slave",
  432. slave_ifname);
  433. return 1;
  434. }
  435. strncpy(ifr.ifr_name, master_ifname, IFNAMSIZ);
  436. strncpy(ifr.ifr_slave, slave_ifname, IFNAMSIZ);
  437. if (ioctl(skfd, SIOCBONDRELEASE, &ifr) < 0
  438. && ioctl(skfd, BOND_RELEASE_OLD, &ifr) < 0
  439. ) {
  440. return 1;
  441. }
  442. if (abi_ver < 1) {
  443. /* The driver is using an old ABI, so we'll set the interface
  444. * down to avoid any conflicts due to same MAC/IP
  445. */
  446. res = set_if_down(slave_ifname, slave.flags.ifr_flags);
  447. }
  448. /* set to default mtu */
  449. set_slave_mtu(slave_ifname, 1500);
  450. return res;
  451. }
  452. static int get_if_settings(char *ifname, struct dev_data *dd)
  453. {
  454. int res;
  455. strncpy(dd->mtu.ifr_name, ifname, IFNAMSIZ);
  456. res = ioctl(skfd, SIOCGIFMTU, &dd->mtu);
  457. strncpy(dd->flags.ifr_name, ifname, IFNAMSIZ);
  458. res |= ioctl(skfd, SIOCGIFFLAGS, &dd->flags);
  459. strncpy(dd->hwaddr.ifr_name, ifname, IFNAMSIZ);
  460. res |= ioctl(skfd, SIOCGIFHWADDR, &dd->hwaddr);
  461. return res;
  462. }
  463. static int get_slave_flags(char *slave_ifname)
  464. {
  465. strncpy(slave.flags.ifr_name, slave_ifname, IFNAMSIZ);
  466. return ioctl(skfd, SIOCGIFFLAGS, &slave.flags);
  467. }
  468. static int set_master_hwaddr(char *master_ifname, struct sockaddr *hwaddr)
  469. {
  470. struct ifreq ifr;
  471. strncpy(ifr.ifr_name, master_ifname, IFNAMSIZ);
  472. memcpy(&(ifr.ifr_hwaddr), hwaddr, sizeof(struct sockaddr));
  473. return ioctl(skfd, SIOCSIFHWADDR, &ifr);
  474. }
  475. static int set_slave_hwaddr(char *slave_ifname, struct sockaddr *hwaddr)
  476. {
  477. struct ifreq ifr;
  478. strncpy(ifr.ifr_name, slave_ifname, IFNAMSIZ);
  479. memcpy(&(ifr.ifr_hwaddr), hwaddr, sizeof(struct sockaddr));
  480. return ioctl(skfd, SIOCSIFHWADDR, &ifr);
  481. }
  482. static int set_slave_mtu(char *slave_ifname, int mtu)
  483. {
  484. struct ifreq ifr;
  485. ifr.ifr_mtu = mtu;
  486. strncpy(ifr.ifr_name, slave_ifname, IFNAMSIZ);
  487. return ioctl(skfd, SIOCSIFMTU, &ifr);
  488. }
  489. static int set_if_flags(char *ifname, short flags)
  490. {
  491. struct ifreq ifr;
  492. ifr.ifr_flags = flags;
  493. strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
  494. return ioctl(skfd, SIOCSIFFLAGS, &ifr);
  495. }
  496. static int set_if_up(char *ifname, short flags)
  497. {
  498. int res = set_if_flags(ifname, flags | IFF_UP);
  499. if (res)
  500. bb_perror_msg("%s: can't up", ifname);
  501. return res;
  502. }
  503. static int set_if_down(char *ifname, short flags)
  504. {
  505. int res = set_if_flags(ifname, flags & ~IFF_UP);
  506. if (res)
  507. bb_perror_msg("%s: can't down", ifname);
  508. return res;
  509. }
  510. static int clear_if_addr(char *ifname)
  511. {
  512. struct ifreq ifr;
  513. strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
  514. ifr.ifr_addr.sa_family = AF_INET;
  515. memset(ifr.ifr_addr.sa_data, 0, sizeof(ifr.ifr_addr.sa_data));
  516. return ioctl(skfd, SIOCSIFADDR, &ifr);
  517. }
  518. static int set_if_addr(char *master_ifname, char *slave_ifname)
  519. {
  520. static const struct {
  521. int g_ioctl;
  522. int s_ioctl;
  523. } ifra[] = {
  524. { SIOCGIFADDR, SIOCSIFADDR },
  525. { SIOCGIFDSTADDR, SIOCSIFDSTADDR },
  526. { SIOCGIFBRDADDR, SIOCSIFBRDADDR },
  527. { SIOCGIFNETMASK, SIOCSIFNETMASK },
  528. };
  529. struct ifreq ifr;
  530. int res;
  531. int i;
  532. for (i = 0; i < ARRAY_SIZE(ifra); i++) {
  533. strncpy(ifr.ifr_name, master_ifname, IFNAMSIZ);
  534. res = ioctl(skfd, ifra[i].g_ioctl, &ifr);
  535. if (res < 0) {
  536. ifr.ifr_addr.sa_family = AF_INET;
  537. memset(ifr.ifr_addr.sa_data, 0,
  538. sizeof(ifr.ifr_addr.sa_data));
  539. }
  540. strncpy(ifr.ifr_name, slave_ifname, IFNAMSIZ);
  541. res = ioctl(skfd, ifra[i].s_ioctl, &ifr);
  542. if (res < 0)
  543. return res;
  544. }
  545. return 0;
  546. }