#include "svec.h"
#include "vlog.h"
-VLOG_DEFINE_THIS_MODULE(netdev_linux)
+VLOG_DEFINE_THIS_MODULE(netdev_linux);
\f
/* These were introduced in Linux 2.6.14, so they might be missing if we have
* old headers. */
/* Creates the netdev device of 'type' with 'name'. */
static int
-netdev_linux_create_system(const char *name, const char *type OVS_UNUSED,
- const struct shash *args, struct netdev_dev **netdev_devp)
+netdev_linux_create_system(const struct netdev_class *class OVS_UNUSED,
+ const char *name, const struct shash *args,
+ struct netdev_dev **netdev_devp)
{
struct netdev_dev_linux *netdev_dev;
int error;
* buffers, across all readers. Therefore once data is read it will
* be unavailable to other reads for tap devices. */
static int
-netdev_linux_create_tap(const char *name, const char *type OVS_UNUSED,
- const struct shash *args, struct netdev_dev **netdev_devp)
+netdev_linux_create_tap(const struct netdev_class *class OVS_UNUSED,
+ const char *name, const struct shash *args,
+ struct netdev_dev **netdev_devp)
{
struct netdev_dev_linux *netdev_dev;
struct tap_state *state;
int error;
tcmsg = tc_make_request(netdev, RTM_DELQDISC, 0, &request);
+ if (!tcmsg) {
+ return ENODEV;
+ }
tcmsg->tcm_handle = tc_make_handle(0xffff, 0);
tcmsg->tcm_parent = TC_H_INGRESS;
nl_msg_put_string(&request, TCA_KIND, "ingress");
netdev_dev_linux_cast(netdev_get_dev(netdev));
struct tc_queue *queue;
- HMAP_FOR_EACH_IN_BUCKET (queue, struct tc_queue, hmap_node,
- hash, &netdev_dev->tc->queues) {
+ HMAP_FOR_EACH_IN_BUCKET (queue, hmap_node, hash, &netdev_dev->tc->queues) {
if (queue->queue_id == queue_id) {
return queue;
}
}
}
-static void
+static bool
start_queue_dump(const struct netdev *netdev, struct nl_dump *dump)
{
struct ofpbuf request;
struct tcmsg *tcmsg;
tcmsg = tc_make_request(netdev, RTM_GETTCLASS, 0, &request);
+ if (!tcmsg) {
+ return false;
+ }
tcmsg->tcm_parent = 0;
nl_dump_start(dump, rtnl_sock, &request);
ofpbuf_uninit(&request);
+ return true;
}
static int
last_error = 0;
shash_init(&details);
- HMAP_FOR_EACH (queue, struct tc_queue, hmap_node,
- &netdev_dev->tc->queues) {
+ HMAP_FOR_EACH (queue, hmap_node, &netdev_dev->tc->queues) {
shash_clear(&details);
error = netdev_dev->tc->ops->class_get(netdev, queue, &details);
}
last_error = 0;
- start_queue_dump(netdev, &dump);
+ if (!start_queue_dump(netdev, &dump)) {
+ return ENODEV;
+ }
while (nl_dump_next(&dump, &msg)) {
error = netdev_dev->tc->ops->class_dump_stats(netdev, &msg, cb, aux);
if (error) {
poll_notify(struct list *list)
{
struct netdev_linux_notifier *notifier;
- LIST_FOR_EACH (notifier, struct netdev_linux_notifier, node, list) {
+ LIST_FOR_EACH (notifier, node, list) {
struct netdev_notifier *n = ¬ifier->notifier;
n->cb(n);
}
tcmsg = tc_make_request(netdev, RTM_NEWQDISC,
NLM_F_EXCL | NLM_F_CREATE, &request);
+ if (!tcmsg) {
+ return ENODEV;
+ }
tcmsg->tcm_handle = tc_make_handle(1, 0);
tcmsg->tcm_parent = TC_H_ROOT;
memset(&opt, 0, sizeof opt);
opt.rate2quantum = 10;
opt.version = 3;
- opt.defcls = 0;
+ opt.defcls = 1;
opt_offset = nl_msg_start_nested(&request, TCA_OPTIONS);
nl_msg_put_unspec(&request, TCA_HTB_INIT, &opt, sizeof opt);
opt.prio = class->priority;
tcmsg = tc_make_request(netdev, RTM_NEWTCLASS, NLM_F_CREATE, &request);
+ if (!tcmsg) {
+ return ENODEV;
+ }
tcmsg->tcm_handle = handle;
tcmsg->tcm_parent = parent;
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 */
static int
htb_tc_load(struct netdev *netdev, struct ofpbuf *nlmsg OVS_UNUSED)
{
- struct shash details = SHASH_INITIALIZER(&details);
struct ofpbuf msg;
struct nl_dump dump;
struct htb_class hc;
htb = htb_install__(netdev, hc.max_rate);
/* Get queues. */
- start_queue_dump(netdev, &dump);
- shash_init(&details);
+ if (!start_queue_dump(netdev, &dump)) {
+ return ENODEV;
+ }
while (nl_dump_next(&dump, &msg)) {
unsigned int queue_id;
struct htb *htb = CONTAINER_OF(tc, struct htb, tc);
struct htb_class *hc, *next;
- HMAP_FOR_EACH_SAFE (hc, next, struct htb_class, tc_queue.hmap_node,
- &htb->tc.queues) {
+ HMAP_FOR_EACH_SAFE (hc, next, tc_queue.hmap_node, &htb->tc.queues) {
hmap_remove(&htb->tc.queues, &hc->tc_queue.hmap_node);
free(hc);
}
major = tc_get_major(handle);
minor = tc_get_minor(handle);
if (major == 1 && minor > 0 && minor <= HTB_N_QUEUES) {
- (*cb)(tc_get_minor(handle), &stats, aux);
+ (*cb)(minor - 1, &stats, aux);
}
return 0;
}
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
int error;
tcmsg = tc_make_request(netdev, RTM_GETTCLASS, NLM_F_ECHO, &request);
+ if (!tcmsg) {
+ return ENODEV;
+ }
tcmsg->tcm_handle = handle;
tcmsg->tcm_parent = parent;
int error;
tcmsg = tc_make_request(netdev, RTM_DELTCLASS, 0, &request);
+ if (!tcmsg) {
+ return ENODEV;
+ }
tcmsg->tcm_handle = handle;
tcmsg->tcm_parent = 0;
int error;
tcmsg = tc_make_request(netdev, RTM_DELQDISC, 0, &request);
+ if (!tcmsg) {
+ return ENODEV;
+ }
tcmsg->tcm_handle = tc_make_handle(1, 0);
tcmsg->tcm_parent = TC_H_ROOT;
* We could check for Linux 2.6.35+ and use a more straightforward method
* there. */
tcmsg = tc_make_request(netdev, RTM_GETQDISC, NLM_F_ECHO, &request);
+ if (!tcmsg) {
+ return ENODEV;
+ }
tcmsg->tcm_handle = tc_make_handle(1, 0);
tcmsg->tcm_parent = 0;
/* 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)
{