geneve: make geneve_fill_info() RTNL independent

Now that geneve->cfg is an RCU-protected pointer, update
geneve_fill_info() to read the configuration under RCU read lock
instead of relying on RTNL.

Also add const qualifiers to the dereferenced pointers where appropriate
and fix local variable declaration ordering.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
Link: https://patch.msgid.link/20260707145331.3717941-4-edumazet@google.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
Eric Dumazet 2026-07-07 14:53:30 +00:00 committed by Paolo Abeni
parent 0ba269933f
commit 5415c41a83

View File

@ -2464,17 +2464,27 @@ static size_t geneve_get_size(const struct net_device *dev)
static int geneve_fill_info(struct sk_buff *skb, const struct net_device *dev)
{
struct geneve_dev *geneve = netdev_priv(dev);
struct geneve_config *cfg = rtnl_dereference(geneve->cfg);
struct ip_tunnel_info *info = &cfg->info;
bool ttl_inherit = cfg->ttl_inherit;
bool metadata = cfg->collect_md;
struct ifla_geneve_port_range ports = {
.low = htons(cfg->port_min),
.high = htons(cfg->port_max),
};
const struct geneve_dev *geneve = netdev_priv(dev);
struct ifla_geneve_port_range ports;
const struct geneve_config *cfg;
const struct ip_tunnel_info *info;
bool ttl_inherit, metadata;
__u8 tmp_vni[3];
__u32 vni;
int err = 0;
rcu_read_lock();
cfg = rcu_dereference(geneve->cfg);
if (!cfg) {
err = -ENODEV;
goto out;
}
info = &cfg->info;
ttl_inherit = cfg->ttl_inherit;
metadata = cfg->collect_md;
ports.low = htons(cfg->port_min);
ports.high = htons(cfg->port_max);
tunnel_id_to_vni(info->key.tun_id, tmp_vni);
vni = (tmp_vni[0] << 16) | (tmp_vni[1] << 8) | tmp_vni[2];
@ -2554,10 +2564,13 @@ static int geneve_fill_info(struct sk_buff *skb, const struct net_device *dev)
nla_put_flag(skb, IFLA_GENEVE_GRO_HINT))
goto nla_put_failure;
return 0;
out:
rcu_read_unlock();
return err;
nla_put_failure:
return -EMSGSIZE;
err = -EMSGSIZE;
goto out;
}
static struct rtnl_link_ops geneve_link_ops __read_mostly = {