280
* @ctl: bridge control pointer
281
* @ifname: interface name get MTU for
283
* This function gets the @mtu value set for a given interface @ifname.
285
* Returns the MTU value in case of success.
286
* On error, returns -1 and sets errno accordingly
288
static int ifGetMtu(brControl *ctl, const char *ifname)
293
if (!ctl || !ifname) {
298
if ((len = strlen(ifname)) >= BR_IFNAME_MAXLEN) {
303
memset(&ifr, 0, sizeof(struct ifreq));
305
strncpy(ifr.ifr_name, ifname, len);
306
ifr.ifr_name[len] = '\0';
308
if (ioctl(ctl->fd, SIOCGIFMTU, &ifr))
317
* @ctl: bridge control pointer
318
* @ifname: interface name to set MTU for
321
* This function sets the @mtu for a given interface @ifname. Typically
322
* used on a tap device to set up for Jumbo Frames.
324
* Returns 0 in case of success or an errno code in case of failure.
326
static int ifSetMtu(brControl *ctl, const char *ifname, int mtu)
334
if ((len = strlen(ifname)) >= BR_IFNAME_MAXLEN)
337
memset(&ifr, 0, sizeof(struct ifreq));
339
strncpy(ifr.ifr_name, ifname, len);
340
ifr.ifr_name[len] = '\0';
343
return ioctl(ctl->fd, SIOCSIFMTU, &ifr) == 0 ? 0 : errno;
348
* @ctl: bridge control pointer
349
* @bridge: name of the bridge interface
350
* @ifname: name of the interface whose MTU we want to set
352
* Sets the interface mtu to the same MTU of the bridge
354
* Returns 0 in case of success or an errno code in case of failure.
356
static int brSetInterfaceMtu(brControl *ctl,
360
int mtu = ifGetMtu(ctl, bridge);
365
return ifSetMtu(ctl, ifname, mtu);
280
370
* @ctl: bridge control pointer
281
371
* @bridge: the bridge name
336
426
if (ioctl(fd, TUNSETIFF, &try) == 0) {
427
/* We need to set the interface MTU before adding it
428
* to the bridge, because the bridge will have its
429
* MTU adjusted automatically when we add the new interface.
431
if ((errno = brSetInterfaceMtu(ctl, bridge, try.ifr_name)))
337
433
if ((errno = brAddInterface(ctl, bridge, try.ifr_name)))
339
435
if ((errno = brSetInterfaceUp(ctl, try.ifr_name, 1)))