tunnel: Accept 'set options:tos' as hex value.
[sliver-openvswitch.git] / lib / netdev-vport.c
index 7bd50a4..a9eb3eb 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2011 Nicira Networks.
+ * Copyright (c) 2010, 2011, 2012 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -198,6 +198,7 @@ netdev_vport_destroy(struct netdev_dev *netdev_dev_)
 {
     struct netdev_dev_vport *netdev_dev = netdev_dev_vport_cast(netdev_dev_);
 
+    ofpbuf_delete(netdev_dev->options);
     route_table_unregister();
     free(netdev_dev);
 }
@@ -611,7 +612,12 @@ parse_tunnel_config(const char *name, const char *type,
             if (!strcmp(node->data, "inherit")) {
                 flags |= TNL_F_TOS_INHERIT;
             } else {
-                nl_msg_put_u8(options, OVS_TUNNEL_ATTR_TOS, atoi(node->data));
+                char *endptr;
+                int tos;
+                tos = strtol(node->data, &endptr, 0);
+                if (*endptr == '\0') {
+                    nl_msg_put_u8(options, OVS_TUNNEL_ATTR_TOS, tos);
+                }
             }
         } else if (!strcmp(node->name, "ttl")) {
             if (!strcmp(node->data, "inherit")) {
@@ -813,7 +819,7 @@ unparse_tunnel_config(const char *name OVS_UNUSED, const char *type OVS_UNUSED,
         smap_add(args, "tos", "inherit");
     } else if (a[OVS_TUNNEL_ATTR_TOS]) {
         int tos = nl_attr_get_u8(a[OVS_TUNNEL_ATTR_TOS]);
-        shash_add(args, "tos", xasprintf("%d", tos));
+        shash_add(args, "tos", xasprintf("0x%x", tos));
     }
 
     if (flags & TNL_F_CSUM) {