CentOS 6.5下VLAN设备的性能问题(2)

2.6.32-431

# ethtool -k eth1.11 Features for eth1.11: rx-checksumming: on tx-checksumming: on scatter-gather: on tcp-segmentation-offload: on udp-fragmentation-offload: off generic-segmentation-offload: on generic-receive-offload: on large-receive-offload: off rx-vlan-offload: off tx-vlan-offload: off ntuple-filters: off receive-hashing: off

对于CentOS6.5(2.6.32-431),是从/sys/class/net/${ethX}/features读取features:

#cat /sys/class/net/eth1.11/features 0x114833 -------------------------- 1 0001 0100 1000 0011 0011 0x114833 1 0000 0000 0000 NETIF_F_LLTX 4096 1000 0000 0000 NETIF_F_GSO 2048 1 0000 0000 0000 0000 NETIF_F_TSO 1<<16 100 0000 0000 0000 NETIF_F_GRO 16384 01 NETIF_F_SG 1 10 NETIF_F_IP_CSUM 2 1 0000 NETIF_F_IPV6_CSUM 16 10 0000 NETIF_F_HIGHDMA 32 1 0000 0000 0000 0000 0000 NETIF_F_TSO6 (1<<20)

可以看到,CentOS6.5的内核对于VLAN设备,没有设置NETIF_F_LLTX标志。

3.10.x

对于3.10.x内核,已经没有/sys/class/net/${ethX}/features,但是内核支持ETHTOOL_GFEATURES命令(2.6.32-431不支持该命令),ethtool通过ETHTOOL_GFEATURES获取网络设备的features:

//net/core/ethtool.c int dev_ethtool(struct net *net, struct ifreq *ifr) { case ETHTOOL_GFEATURES: rc = ethtool_get_features(dev, useraddr); break; # ./ethtool -k eth1.11 | grep tx-lockless tx-lockless: on [fixed] # ./ethtool -k eth1 | grep tx-lockless tx-lockless: off [fixed]

从上面可以确认,3.10.x的内核对VLAN设备的确设置了NETIF_F_LLTX标志。

ethtool的实现

//ethtool-3.5 static struct feature_state * get_features(struct cmd_context *ctx, const struct feature_defs *defs) { ... if (defs->n_features) { ///内核支持ETHTOOL_GFEATURES state->features.cmd = ETHTOOL_GFEATURES; state->features.size = FEATURE_BITS_TO_BLOCKS(defs->n_features); err = send_ioctl(ctx, &state->features); if (err) perror("Cannot get device generic features"); else allfail = 0; } else { /* We should have got VLAN tag offload flags through * ETHTOOL_GFLAGS. However, prior to Linux 2.6.37 * they were not exposed in this way - and since VLAN * tag offload was defined and implemented by many * drivers, we shouldn't assume they are off. * Instead, since these feature flag values were * stable, read them from sysfs. */ char buf[20]; ///从/sys/class/net/%s/features读取features if (get_netdev_attr(ctx, "features", buf, sizeof(buf)) > 0) state->off_flags |= strtoul(buf, NULL, 0) & (ETH_FLAG_RXVLAN | ETH_FLAG_TXVLAN); } static int get_netdev_attr(struct cmd_context *ctx, const char *name, char *buf, size_t buf_len) { #ifdef TEST_ETHTOOL errno = ENOENT; return -1; #else char path[40 + IFNAMSIZ]; ssize_t len; int fd; len = snprintf(path, sizeof(path), "/sys/class/net/%s/%s", ctx->devname, name); assert(len < sizeof(path)); fd = open(path, O_RDONLY); if (fd < 0) return fd; len = read(fd, buf, buf_len - 1); if (len >= 0) buf[len] = 0; close(fd); return len; #endif } 

更多CentOS相关信息见CentOS 专题页面 ?tid=14

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/15829.html