-/* Set the features advertised by 'netdev' to 'advertise'. */
-static int
-netdev_linux_set_advertisements(struct netdev *netdev, uint32_t advertise)
-{
- struct ethtool_cmd ecmd;
- int error;
-
- memset(&ecmd, 0, sizeof ecmd);
- error = netdev_linux_do_ethtool(netdev_get_name(netdev), &ecmd,
- ETHTOOL_GSET, "ETHTOOL_GSET");
- if (error) {
- return error;
- }
-
- ecmd.advertising = 0;
- if (advertise & OFPPF_10MB_HD) {
- ecmd.advertising |= ADVERTISED_10baseT_Half;
- }
- if (advertise & OFPPF_10MB_FD) {
- ecmd.advertising |= ADVERTISED_10baseT_Full;
- }
- if (advertise & OFPPF_100MB_HD) {
- ecmd.advertising |= ADVERTISED_100baseT_Half;
- }
- if (advertise & OFPPF_100MB_FD) {
- ecmd.advertising |= ADVERTISED_100baseT_Full;
- }
- if (advertise & OFPPF_1GB_HD) {
- ecmd.advertising |= ADVERTISED_1000baseT_Half;
- }
- if (advertise & OFPPF_1GB_FD) {
- ecmd.advertising |= ADVERTISED_1000baseT_Full;
- }
- if (advertise & OFPPF_10GB_FD) {
- ecmd.advertising |= ADVERTISED_10000baseT_Full;
- }
- if (advertise & OFPPF_COPPER) {
- ecmd.advertising |= ADVERTISED_TP;
- }
- if (advertise & OFPPF_FIBER) {
- ecmd.advertising |= ADVERTISED_FIBRE;
- }
- if (advertise & OFPPF_AUTONEG) {
- ecmd.advertising |= ADVERTISED_Autoneg;
- }
- if (advertise & OFPPF_PAUSE) {
- ecmd.advertising |= ADVERTISED_Pause;
- }
- if (advertise & OFPPF_PAUSE_ASYM) {
- ecmd.advertising |= ADVERTISED_Asym_Pause;
- }
- return netdev_linux_do_ethtool(netdev_get_name(netdev), &ecmd,
- ETHTOOL_SSET, "ETHTOOL_SSET");
-}
-
-/* If 'netdev_name' is the name of a VLAN network device (e.g. one created with
- * vconfig(8)), sets '*vlan_vid' to the VLAN VID associated with that device
- * and returns 0. Otherwise returns a errno value (specifically ENOENT if
- * 'netdev_name' is the name of a network device that is not a VLAN device) and
- * sets '*vlan_vid' to -1. */
-static int
-netdev_linux_get_vlan_vid(const struct netdev *netdev, int *vlan_vid)
-{
- const char *netdev_name = netdev_get_name(netdev);
- struct ds line = DS_EMPTY_INITIALIZER;
- FILE *stream = NULL;
- int error;
- char *fn;
-
- COVERAGE_INC(netdev_get_vlan_vid);
- fn = xasprintf("/proc/net/vlan/%s", netdev_name);
- stream = fopen(fn, "r");
- if (!stream) {
- error = errno;
- goto done;
- }
-
- if (ds_get_line(&line, stream)) {
- if (ferror(stream)) {
- error = errno;
- VLOG_ERR_RL(&rl, "error reading \"%s\": %s", fn, strerror(errno));
- } else {
- error = EPROTO;
- VLOG_ERR_RL(&rl, "unexpected end of file reading \"%s\"", fn);
- }
- goto done;
- }
-
- if (!sscanf(ds_cstr(&line), "%*s VID: %d", vlan_vid)) {
- error = EPROTO;
- VLOG_ERR_RL(&rl, "parse error reading \"%s\" line 1: \"%s\"",
- fn, ds_cstr(&line));
- goto done;
- }
-
- error = 0;
-
-done:
- free(fn);
- if (stream) {
- fclose(stream);
- }
- ds_destroy(&line);
- if (error) {
- *vlan_vid = -1;
- }
- return error;
-}
-
-#define POLICE_ADD_CMD "/sbin/tc qdisc add dev %s handle ffff: ingress"
-#define POLICE_CONFIG_CMD "/sbin/tc filter add dev %s parent ffff: protocol ip prio 50 u32 match ip src 0.0.0.0/0 police rate %dkbit burst %dk mtu 65535 drop flowid :1"
-
-/* Remove ingress policing from 'netdev'. Returns 0 if successful, otherwise a
- * positive errno value.
- *
- * This function is equivalent to running
- * /sbin/tc qdisc del dev %s handle ffff: ingress
- * but it is much, much faster.
- */