summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Mayfield <jmayfield@cradlepoint.com>2012-08-17 18:16:44 -0600
committerThomas Graf <tgraf@redhat.com>2012-08-29 12:17:24 +0200
commitde28daf2269a5c7d55e6f1f50f1c1eff4db27a15 (patch)
tree2cac92ecfe7f4fe6127ecaa34912e3935f8af3b3
parent97d2460fabaabffce0d224bdd24c0bdfee57dbf1 (diff)
downloadlibnl-de28daf2269a5c7d55e6f1f50f1c1eff4db27a15.tar.gz
nl_addr_parse handling of 'default', 'any', and 'all'
I found a small bug in the nl_addr_parse function when being passed the strings "default", "any", or "all". Currently nl_addr_parse will create a zeroed nl_addr with a length corresponding to the family/hint or AF_INET if omitted. This behavior when used in conjunction with the libnl-route library to add default routes to the system has the side effect of creating a route to the host address 0.0.0.0/32. Attached is a patch that matches the iproute2 behavior more closely where we do set the family but the length of the nl_addr is set to 0.
-rw-r--r--lib/addr.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/addr.c b/lib/addr.c
index 3acd9e4..6150d75 100644
--- a/lib/addr.c
+++ b/lib/addr.c
@@ -279,7 +279,9 @@ int nl_addr_parse(const char *addrstr, int hint, struct nl_addr **result)
if (!strcasecmp(str, "default") ||
!strcasecmp(str, "all") ||
!strcasecmp(str, "any")) {
-
+
+ len = 0;
+
switch (hint) {
case AF_INET:
case AF_UNSPEC:
@@ -287,17 +289,14 @@ int nl_addr_parse(const char *addrstr, int hint, struct nl_addr **result)
* no hint given the user wants to have a IPv4
* address given back. */
family = AF_INET;
- len = 4;
goto prefix;
case AF_INET6:
family = AF_INET6;
- len = 16;
goto prefix;
case AF_LLC:
family = AF_LLC;
- len = 6;
goto prefix;
default: