* to the controller or adding a vlan tag, plus an extra 2 bytes to
* allow IP headers to be aligned on a 4-byte boundary. */
const int headroom = 128 + 2;
- buffer = buffer_new(ETH_TOTAL_MAX + headroom);
+ const int hard_header = VLAN_ETH_HEADER_LEN;
+ const int mtu = netdev_get_mtu(p->netdev);
+ buffer = buffer_new(headroom + hard_header + mtu);
buffer->data += headroom;
}
error = netdev_recv(p->netdev, buffer, false);
int fd;
uint8_t etheraddr[ETH_ADDR_LEN];
int speed;
+ int mtu;
uint32_t features;
int save_flags;
};
socklen_t rcvbuf_len;
size_t rcvbuf;
uint8_t etheraddr[ETH_ADDR_LEN];
+ int mtu;
int error;
struct netdev *netdev;
rcvbuf -= n_bytes;
}
- /* Get ethernet device index and hardware address. */
+ /* Get ethernet device index. */
strncpy(ifr.ifr_name, name, sizeof ifr.ifr_name);
if (ioctl(fd, SIOCGIFINDEX, &ifr) < 0) {
VLOG_ERR("ioctl(SIOCGIFINDEX) on %s device failed: %s",
goto error;
}
ifindex = ifr.ifr_ifindex;
+
+ /* Get MAC address. */
if (ioctl(fd, SIOCGIFHWADDR, &ifr) < 0) {
VLOG_ERR("ioctl(SIOCGIFHWADDR) on %s device failed: %s",
name, strerror(errno));
}
memcpy(etheraddr, ifr.ifr_hwaddr.sa_data, sizeof etheraddr);
+ /* Get MTU. */
+ if (ioctl(fd, SIOCGIFMTU, &ifr) < 0) {
+ VLOG_ERR("ioctl(SIOCGIFMTU) on %s device failed: %s",
+ name, strerror(errno));
+ goto error;
+ }
+ mtu = ifr.ifr_mtu;
+
/* Allocate network device. */
netdev = xmalloc(sizeof *netdev);
netdev->name = xstrdup(name);
netdev->fd = fd;
memcpy(netdev->etheraddr, etheraddr, sizeof etheraddr);
+ netdev->mtu = mtu;
/* Get speed, features. */
do_ethtool(netdev);
return netdev->name;
}
+int
+netdev_get_mtu(const struct netdev *netdev)
+{
+ return netdev->mtu;
+}
+
int
netdev_get_speed(const struct netdev *netdev)
{
const uint8_t *netdev_get_etheraddr(const struct netdev *);
int netdev_get_fd(const struct netdev *);
const char *netdev_get_name(const struct netdev *);
+int netdev_get_mtu(const struct netdev *);
int netdev_get_speed(const struct netdev *);
uint32_t netdev_get_features(const struct netdev *);