X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fnetdev-linux.c;h=c468a035866de40252e1ada339d9a6109c9c03c3;hb=refs%2Fheads%2Flts-1.0a;hp=8cd40cd2f6a7ab8d364675bfcf0d62f1a4cc8c7c;hpb=c1c9c9c4b636ab2acf2f75024c282a9a497ca9a9;p=sliver-openvswitch.git diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c index 8cd40cd2f..c468a0358 100644 --- a/lib/netdev-linux.c +++ b/lib/netdev-linux.c @@ -53,7 +53,6 @@ #include "netlink.h" #include "ofpbuf.h" #include "openflow/openflow.h" -#include "openvswitch/gre.h" #include "packets.h" #include "poll-loop.h" #include "port-array.h" @@ -61,9 +60,9 @@ #include "socket-util.h" #include "shash.h" #include "svec.h" - -#define THIS_MODULE VLM_netdev_linux #include "vlog.h" + +VLOG_DEFINE_THIS_MODULE(netdev_linux) /* These were introduced in Linux 2.6.14, so they might be missing if we have * old headers. */ @@ -1009,7 +1008,7 @@ netdev_linux_update_is_pseudo(struct netdev_dev_linux *netdev_dev) if (!(netdev_dev->cache_valid & VALID_IS_PSEUDO)) { const char *name = netdev_dev_get_name(&netdev_dev->netdev_dev); const char *type = netdev_dev_get_type(&netdev_dev->netdev_dev); - + netdev_dev->is_tap = !strcmp(type, "tap"); netdev_dev->is_internal = false; if (!netdev_dev->is_tap) { @@ -1625,7 +1624,7 @@ start_queue_dump(const struct netdev *netdev, struct nl_dump *dump) struct tcmsg *tcmsg; tcmsg = tc_make_request(netdev, RTM_GETTCLASS, 0, &request); - tcmsg->tcm_parent = TC_H_ROOT; + tcmsg->tcm_parent = 0; nl_dump_start(dump, rtnl_sock, &request); ofpbuf_uninit(&request); } @@ -1873,7 +1872,7 @@ netdev_linux_get_next_hop(const struct in_addr *host, struct in_addr *next_hop, iface, &dest, &gateway, &flags, &refcnt, &use, &metric, &mask, &mtu, &window, &irtt) != 11) { - VLOG_WARN_RL(&rl, "%s: could not parse line %d: %s", + VLOG_WARN_RL(&rl, "%s: could not parse line %d: %s", fn, ln, line); continue; } @@ -1883,7 +1882,7 @@ netdev_linux_get_next_hop(const struct in_addr *host, struct in_addr *next_hop, } /* The output of 'dest', 'mask', and 'gateway' were given in - * network byte order, so we don't need need any endian + * network byte order, so we don't need need any endian * conversions here. */ if ((dest & mask) == (host->s_addr & mask)) { if (!gateway) { @@ -2341,8 +2340,10 @@ htb_parse_tcmsg__(struct ofpbuf *tcmsg, unsigned int *queue_id, error = tc_parse_class(tcmsg, &handle, &nl_options, stats); if (!error && queue_id) { - if (tc_get_major(handle) == 1 && tc_get_minor(handle) < HTB_N_QUEUES) { - *queue_id = tc_get_minor(handle); + unsigned int major = tc_get_major(handle); + unsigned int minor = tc_get_minor(handle); + if (major == 1 && minor > 0 && minor <= HTB_N_QUEUES) { + *queue_id = minor - 1; } else { error = EPROTO; } @@ -2383,13 +2384,13 @@ htb_parse_class_details__(struct netdev *netdev, const char *priority_s = shash_find_data(details, "priority"); int mtu; - /* min-rate */ + /* min-rate. Don't allow a min-rate below 1500 bytes/s. */ if (!min_rate_s) { /* min-rate is required. */ return EINVAL; } hc->min_rate = strtoull(min_rate_s, NULL, 10) / 8; - hc->min_rate = MAX(hc->min_rate, 0); + hc->min_rate = MAX(hc->min_rate, 1500); hc->min_rate = MIN(hc->min_rate, htb->max_rate); /* max-rate */ @@ -2567,7 +2568,7 @@ htb_class_set(struct netdev *netdev, unsigned int queue_id, return error; } - error = htb_setup_class__(netdev, tc_make_handle(1, queue_id), + error = htb_setup_class__(netdev, tc_make_handle(1, queue_id + 1), tc_make_handle(1, 0xfffe), &hc); if (error) { return error; @@ -2587,7 +2588,7 @@ htb_class_delete(struct netdev *netdev, unsigned int queue_id) hc = port_array_get(&htb->tc.queues, queue_id); assert(hc != NULL); - error = tc_delete_class(netdev, tc_make_handle(1, queue_id)); + error = tc_delete_class(netdev, tc_make_handle(1, queue_id + 1)); if (!error) { free(hc); port_array_delete(&htb->tc.queues, queue_id); @@ -2599,7 +2600,7 @@ static int htb_class_get_stats(const struct netdev *netdev, unsigned int queue_id, struct netdev_queue_stats *stats) { - return htb_query_class__(netdev, tc_make_handle(1, queue_id), + return htb_query_class__(netdev, tc_make_handle(1, queue_id + 1), tc_make_handle(1, 0xfffe), NULL, stats); } @@ -2609,7 +2610,7 @@ htb_class_dump_stats(const struct netdev *netdev OVS_UNUSED, netdev_dump_queue_stats_cb *cb, void *aux) { struct netdev_queue_stats stats; - unsigned int handle; + unsigned int handle, major, minor; int error; error = tc_parse_class(nlmsg, &handle, NULL, &stats); @@ -2617,8 +2618,10 @@ htb_class_dump_stats(const struct netdev *netdev OVS_UNUSED, return error; } - if (tc_get_major(handle) == 1 && tc_get_minor(handle) < HTB_N_QUEUES) { - (*cb)(tc_get_minor(handle), &stats, aux); + major = tc_get_major(handle); + minor = tc_get_minor(handle); + if (major == 1 && minor > 0 && minor <= HTB_N_QUEUES) { + (*cb)(minor - 1, &stats, aux); } return 0; } @@ -2895,7 +2898,7 @@ tc_bytes_to_ticks(unsigned int rate, unsigned int size) if (!buffer_hz) { read_psched(); } - return ((unsigned long long int) ticks_per_s * size) / rate; + return rate ? ((unsigned long long int) ticks_per_s * size) / rate : 0; } /* Returns the number of bytes that need to be reserved for qdisc buffering at @@ -3241,9 +3244,7 @@ tc_put_rtab(struct ofpbuf *msg, uint16_t type, const struct tc_ratespec *rate) /* Calculates the proper value of 'buffer' or 'cbuffer' in HTB options given a * rate of 'Bps' bytes per second, the specified 'mtu', and a user-requested * burst size of 'burst_bytes'. (If no value was requested, a 'burst_bytes' of - * 0 is fine.) - * - * This */ + * 0 is fine.) */ static int tc_calc_buffer(unsigned int Bps, int mtu, uint64_t burst_bytes) {