aboutsummaryrefslogtreecommitdiff
path: root/net/net6.c
diff options
context:
space:
mode:
authorSean Edmond2023-01-06 14:22:55 -0800
committerTom Rini2023-02-02 14:44:53 -0500
commit796e549822bdb49128578d8ae82d28a5249b4816 (patch)
tree54a13359ccbbec21a22e6f0be24b9f082ba65f87 /net/net6.c
parent878a20aa15880e8b0cc2009331e7b207b7c668c0 (diff)
net: ipv6: Fix IPv6 netmask parsing
It should be possible to specify a netmask when setting a static IPv6 address. For example: setenv ip6addr 2001:cafe:cafe:cafe::100/64 The net_prefix_length and net_ip6 should be updated properly. Signed-off-by: Sean Edmond <seanedmond@microsoft.com> Reviewed-by: Viacheslav Mitrofanov <v.v.mitrofanov@yadro.com> Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Diffstat (limited to 'net/net6.c')
-rw-r--r--net/net6.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/net/net6.c b/net/net6.c
index fdea0787885..75577bcea17 100644
--- a/net/net6.c
+++ b/net/net6.c
@@ -47,10 +47,13 @@ static int on_ip6addr(const char *name, const char *value, enum env_op op,
}
mask = strchr(value, '/');
- len = strlen(value);
- if (mask)
- net_prefix_length = simple_strtoul(value + len, NULL, 10);
+ if (mask) {
+ net_prefix_length = simple_strtoul(mask + 1, NULL, 10);
+ len = mask - value;
+ } else {
+ len = strlen(value);
+ }
return string_to_ip6(value, len, &net_ip6);
}