Commit d73f80f9 authored by David Ahern's avatar David Ahern Committed by David S. Miller

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: f35b794b ("ipv4: Prepare fib_config for IPv6 gateway")
Reported-by: default avatarGovindarajulu Varadarajan <govind.varadar@gmail.com>
Signed-off-by: default avatarDavid Ahern <dsahern@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 44b9b6ca
...@@ -755,8 +755,9 @@ static int rtm_to_fib_config(struct net *net, struct sk_buff *skb, ...@@ -755,8 +755,9 @@ static int rtm_to_fib_config(struct net *net, struct sk_buff *skb,
break; break;
case RTA_GATEWAY: case RTA_GATEWAY:
has_gw = true; has_gw = true;
cfg->fc_gw_family = AF_INET;
cfg->fc_gw4 = nla_get_be32(attr); cfg->fc_gw4 = nla_get_be32(attr);
if (cfg->fc_gw4)
cfg->fc_gw_family = AF_INET;
break; break;
case RTA_VIA: case RTA_VIA:
has_via = true; has_via = true;
......
...@@ -616,8 +616,9 @@ static int fib_get_nhs(struct fib_info *fi, struct rtnexthop *rtnh, ...@@ -616,8 +616,9 @@ static int fib_get_nhs(struct fib_info *fi, struct rtnexthop *rtnh,
return -EINVAL; return -EINVAL;
} }
if (nla) { if (nla) {
fib_cfg.fc_gw_family = AF_INET;
fib_cfg.fc_gw4 = nla_get_in_addr(nla); fib_cfg.fc_gw4 = nla_get_in_addr(nla);
if (fib_cfg.fc_gw4)
fib_cfg.fc_gw_family = AF_INET;
} else if (nlav) { } else if (nlav) {
ret = fib_gw_from_via(&fib_cfg, nlav, extack); ret = fib_gw_from_via(&fib_cfg, nlav, extack);
if (ret) if (ret)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment