Skip to content

Commit d73f80f

Browse files
dsaherndavem330
authored andcommitted
ipv4: Handle RTA_GATEWAY set to 0
Govindarajulu reported a regression with Network Manager which sends an RTA_GATEWAY attribute with the address set to 0. Fixup the handling of RTA_GATEWAY to only set fc_gw_family if the gateway address is actually set. Fixes: f35b794 ("ipv4: Prepare fib_config for IPv6 gateway") Reported-by: Govindarajulu Varadarajan <[email protected]> Signed-off-by: David Ahern <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 44b9b6c commit d73f80f

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

net/ipv4/fib_frontend.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,8 +755,9 @@ static int rtm_to_fib_config(struct net *net, struct sk_buff *skb,
755755
break;
756756
case RTA_GATEWAY:
757757
has_gw = true;
758-
cfg->fc_gw_family = AF_INET;
759758
cfg->fc_gw4 = nla_get_be32(attr);
759+
if (cfg->fc_gw4)
760+
cfg->fc_gw_family = AF_INET;
760761
break;
761762
case RTA_VIA:
762763
has_via = true;

net/ipv4/fib_semantics.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,8 +616,9 @@ static int fib_get_nhs(struct fib_info *fi, struct rtnexthop *rtnh,
616616
return -EINVAL;
617617
}
618618
if (nla) {
619-
fib_cfg.fc_gw_family = AF_INET;
620619
fib_cfg.fc_gw4 = nla_get_in_addr(nla);
620+
if (fib_cfg.fc_gw4)
621+
fib_cfg.fc_gw_family = AF_INET;
621622
} else if (nlav) {
622623
ret = fib_gw_from_via(&fib_cfg, nlav, extack);
623624
if (ret)

0 commit comments

Comments
 (0)