aboutgitcodebugslistschat
path: root/conf.c
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2021-10-19 09:01:27 +0200
committerStefano Brivio <sbrivio@redhat.com>2021-10-19 09:01:27 +0200
commit17600d6d6ef0edf60bbf64c5bef594a8a07547cc (patch)
tree7985a9dde7c81ba098296fdcfe63c070b4e36253 /conf.c
parent1ac0d52820e0cfd6c7f301e3f5d5717cda4dea88 (diff)
downloadpasst-17600d6d6ef0edf60bbf64c5bef594a8a07547cc.tar
passt-17600d6d6ef0edf60bbf64c5bef594a8a07547cc.tar.gz
passt-17600d6d6ef0edf60bbf64c5bef594a8a07547cc.tar.bz2
passt-17600d6d6ef0edf60bbf64c5bef594a8a07547cc.tar.lz
passt-17600d6d6ef0edf60bbf64c5bef594a8a07547cc.tar.xz
passt-17600d6d6ef0edf60bbf64c5bef594a8a07547cc.tar.zst
passt-17600d6d6ef0edf60bbf64c5bef594a8a07547cc.zip
netlink, conf: Actually get prefix/mask length
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'conf.c')
-rw-r--r--conf.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/conf.c b/conf.c
index 4287630..8e96368 100644
--- a/conf.c
+++ b/conf.c
@@ -469,7 +469,11 @@ static void conf_ip(struct ctx *c)
nl_route(0, c->ifi, AF_INET, &c->gw4);
if (!c->addr4) {
- nl_addr(0, c->ifi, AF_INET, &c->addr4, 0, NULL);
+ int mask_len = 0;
+
+ nl_addr(0, c->ifi, AF_INET, &c->addr4, &mask_len, NULL);
+ c->mask4 = htonl(0xffffffff << (32 - mask_len));
+
if (!c->mask4) {
if (IN_CLASSA(ntohl(c->addr4)))
c->mask4 = htonl(IN_CLASSA_NET);
@@ -492,12 +496,14 @@ static void conf_ip(struct ctx *c)
memset(&c->mac_guest, 0xff, sizeof(c->mac_guest));
if (v6 != IP_VERSION_DISABLED) {
+ int prefix_len = 0;
+
if (IN6_IS_ADDR_UNSPECIFIED(&c->gw6))
nl_route(0, c->ifi, AF_INET6, &c->gw6);
nl_addr(0, c->ifi, AF_INET6,
IN6_IS_ADDR_UNSPECIFIED(&c->addr6) ? &c->addr6 : NULL,
- 0, &c->addr6_ll);
+ &prefix_len, &c->addr6_ll);
memcpy(&c->addr6_seen, &c->addr6, sizeof(c->addr4_seen));
memcpy(&c->addr6_ll_seen, &c->addr6, sizeof(c->addr4_seen));