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

net: ipv4: Plumb extack through route add functions

Plumb extack argument down to route add functions.
Signed-off-by: default avatarDavid Ahern <dsahern@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 863483c9
...@@ -263,7 +263,8 @@ struct fib_table { ...@@ -263,7 +263,8 @@ struct fib_table {
int fib_table_lookup(struct fib_table *tb, const struct flowi4 *flp, int fib_table_lookup(struct fib_table *tb, const struct flowi4 *flp,
struct fib_result *res, int fib_flags); struct fib_result *res, int fib_flags);
int fib_table_insert(struct net *, struct fib_table *, struct fib_config *); int fib_table_insert(struct net *, struct fib_table *, struct fib_config *,
struct netlink_ext_ack *extack);
int fib_table_delete(struct net *, struct fib_table *, struct fib_config *); int fib_table_delete(struct net *, struct fib_table *, struct fib_config *);
int fib_table_dump(struct fib_table *table, struct sk_buff *skb, int fib_table_dump(struct fib_table *table, struct sk_buff *skb,
struct netlink_callback *cb); struct netlink_callback *cb);
......
...@@ -594,7 +594,8 @@ int ip_rt_ioctl(struct net *net, unsigned int cmd, void __user *arg) ...@@ -594,7 +594,8 @@ int ip_rt_ioctl(struct net *net, unsigned int cmd, void __user *arg)
} else { } else {
tb = fib_new_table(net, cfg.fc_table); tb = fib_new_table(net, cfg.fc_table);
if (tb) if (tb)
err = fib_table_insert(net, tb, &cfg); err = fib_table_insert(net, tb,
&cfg, NULL);
else else
err = -ENOBUFS; err = -ENOBUFS;
} }
...@@ -626,14 +627,15 @@ const struct nla_policy rtm_ipv4_policy[RTA_MAX + 1] = { ...@@ -626,14 +627,15 @@ const struct nla_policy rtm_ipv4_policy[RTA_MAX + 1] = {
}; };
static int rtm_to_fib_config(struct net *net, struct sk_buff *skb, static int rtm_to_fib_config(struct net *net, struct sk_buff *skb,
struct nlmsghdr *nlh, struct fib_config *cfg) struct nlmsghdr *nlh, struct fib_config *cfg,
struct netlink_ext_ack *extack)
{ {
struct nlattr *attr; struct nlattr *attr;
int err, remaining; int err, remaining;
struct rtmsg *rtm; struct rtmsg *rtm;
err = nlmsg_validate(nlh, sizeof(*rtm), RTA_MAX, rtm_ipv4_policy, err = nlmsg_validate(nlh, sizeof(*rtm), RTA_MAX, rtm_ipv4_policy,
NULL); extack);
if (err < 0) if (err < 0)
goto errout; goto errout;
...@@ -718,7 +720,7 @@ static int inet_rtm_delroute(struct sk_buff *skb, struct nlmsghdr *nlh, ...@@ -718,7 +720,7 @@ static int inet_rtm_delroute(struct sk_buff *skb, struct nlmsghdr *nlh,
struct fib_table *tb; struct fib_table *tb;
int err; int err;
err = rtm_to_fib_config(net, skb, nlh, &cfg); err = rtm_to_fib_config(net, skb, nlh, &cfg, extack);
if (err < 0) if (err < 0)
goto errout; goto errout;
...@@ -741,7 +743,7 @@ static int inet_rtm_newroute(struct sk_buff *skb, struct nlmsghdr *nlh, ...@@ -741,7 +743,7 @@ static int inet_rtm_newroute(struct sk_buff *skb, struct nlmsghdr *nlh,
struct fib_table *tb; struct fib_table *tb;
int err; int err;
err = rtm_to_fib_config(net, skb, nlh, &cfg); err = rtm_to_fib_config(net, skb, nlh, &cfg, extack);
if (err < 0) if (err < 0)
goto errout; goto errout;
...@@ -751,7 +753,7 @@ static int inet_rtm_newroute(struct sk_buff *skb, struct nlmsghdr *nlh, ...@@ -751,7 +753,7 @@ static int inet_rtm_newroute(struct sk_buff *skb, struct nlmsghdr *nlh,
goto errout; goto errout;
} }
err = fib_table_insert(net, tb, &cfg); err = fib_table_insert(net, tb, &cfg, extack);
errout: errout:
return err; return err;
} }
...@@ -845,7 +847,7 @@ static void fib_magic(int cmd, int type, __be32 dst, int dst_len, struct in_ifad ...@@ -845,7 +847,7 @@ static void fib_magic(int cmd, int type, __be32 dst, int dst_len, struct in_ifad
cfg.fc_scope = RT_SCOPE_HOST; cfg.fc_scope = RT_SCOPE_HOST;
if (cmd == RTM_NEWROUTE) if (cmd == RTM_NEWROUTE)
fib_table_insert(net, tb, &cfg); fib_table_insert(net, tb, &cfg, NULL);
else else
fib_table_delete(net, tb, &cfg); fib_table_delete(net, tb, &cfg);
} }
......
...@@ -28,7 +28,8 @@ static inline void fib_alias_accessed(struct fib_alias *fa) ...@@ -28,7 +28,8 @@ static inline void fib_alias_accessed(struct fib_alias *fa)
/* Exported by fib_semantics.c */ /* Exported by fib_semantics.c */
void fib_release_info(struct fib_info *); void fib_release_info(struct fib_info *);
struct fib_info *fib_create_info(struct fib_config *cfg); struct fib_info *fib_create_info(struct fib_config *cfg,
struct netlink_ext_ack *extack);
int fib_nh_match(struct fib_config *cfg, struct fib_info *fi); int fib_nh_match(struct fib_config *cfg, struct fib_info *fi);
int fib_dump_info(struct sk_buff *skb, u32 pid, u32 seq, int event, u32 tb_id, int fib_dump_info(struct sk_buff *skb, u32 pid, u32 seq, int event, u32 tb_id,
u8 type, __be32 dst, int dst_len, u8 tos, struct fib_info *fi, u8 type, __be32 dst, int dst_len, u8 tos, struct fib_info *fi,
......
...@@ -454,7 +454,8 @@ static int fib_detect_death(struct fib_info *fi, int order, ...@@ -454,7 +454,8 @@ static int fib_detect_death(struct fib_info *fi, int order,
#ifdef CONFIG_IP_ROUTE_MULTIPATH #ifdef CONFIG_IP_ROUTE_MULTIPATH
static int fib_count_nexthops(struct rtnexthop *rtnh, int remaining) static int fib_count_nexthops(struct rtnexthop *rtnh, int remaining,
struct netlink_ext_ack *extack)
{ {
int nhs = 0; int nhs = 0;
...@@ -468,7 +469,8 @@ static int fib_count_nexthops(struct rtnexthop *rtnh, int remaining) ...@@ -468,7 +469,8 @@ static int fib_count_nexthops(struct rtnexthop *rtnh, int remaining)
} }
static int fib_get_nhs(struct fib_info *fi, struct rtnexthop *rtnh, static int fib_get_nhs(struct fib_info *fi, struct rtnexthop *rtnh,
int remaining, struct fib_config *cfg) int remaining, struct fib_config *cfg,
struct netlink_ext_ack *extack)
{ {
int ret; int ret;
...@@ -714,7 +716,7 @@ int fib_nh_match(struct fib_config *cfg, struct fib_info *fi) ...@@ -714,7 +716,7 @@ int fib_nh_match(struct fib_config *cfg, struct fib_info *fi)
* |-> {local prefix} (terminal node) * |-> {local prefix} (terminal node)
*/ */
static int fib_check_nh(struct fib_config *cfg, struct fib_info *fi, static int fib_check_nh(struct fib_config *cfg, struct fib_info *fi,
struct fib_nh *nh) struct fib_nh *nh, struct netlink_ext_ack *extack)
{ {
int err = 0; int err = 0;
struct net *net; struct net *net;
...@@ -797,7 +799,6 @@ static int fib_check_nh(struct fib_config *cfg, struct fib_info *fi, ...@@ -797,7 +799,6 @@ static int fib_check_nh(struct fib_config *cfg, struct fib_info *fi,
if (nh->nh_flags & (RTNH_F_PERVASIVE | RTNH_F_ONLINK)) if (nh->nh_flags & (RTNH_F_PERVASIVE | RTNH_F_ONLINK))
return -EINVAL; return -EINVAL;
rcu_read_lock(); rcu_read_lock();
err = -ENODEV; err = -ENODEV;
in_dev = inetdev_by_index(net, nh->nh_oif); in_dev = inetdev_by_index(net, nh->nh_oif);
...@@ -980,7 +981,8 @@ fib_convert_metrics(struct fib_info *fi, const struct fib_config *cfg) ...@@ -980,7 +981,8 @@ fib_convert_metrics(struct fib_info *fi, const struct fib_config *cfg)
return 0; return 0;
} }
struct fib_info *fib_create_info(struct fib_config *cfg) struct fib_info *fib_create_info(struct fib_config *cfg,
struct netlink_ext_ack *extack)
{ {
int err; int err;
struct fib_info *fi = NULL; struct fib_info *fi = NULL;
...@@ -1000,7 +1002,7 @@ struct fib_info *fib_create_info(struct fib_config *cfg) ...@@ -1000,7 +1002,7 @@ struct fib_info *fib_create_info(struct fib_config *cfg)
#ifdef CONFIG_IP_ROUTE_MULTIPATH #ifdef CONFIG_IP_ROUTE_MULTIPATH
if (cfg->fc_mp) { if (cfg->fc_mp) {
nhs = fib_count_nexthops(cfg->fc_mp, cfg->fc_mp_len); nhs = fib_count_nexthops(cfg->fc_mp, cfg->fc_mp_len, extack);
if (nhs == 0) if (nhs == 0)
goto err_inval; goto err_inval;
} }
...@@ -1062,7 +1064,7 @@ struct fib_info *fib_create_info(struct fib_config *cfg) ...@@ -1062,7 +1064,7 @@ struct fib_info *fib_create_info(struct fib_config *cfg)
if (cfg->fc_mp) { if (cfg->fc_mp) {
#ifdef CONFIG_IP_ROUTE_MULTIPATH #ifdef CONFIG_IP_ROUTE_MULTIPATH
err = fib_get_nhs(fi, cfg->fc_mp, cfg->fc_mp_len, cfg); err = fib_get_nhs(fi, cfg->fc_mp, cfg->fc_mp_len, cfg, extack);
if (err != 0) if (err != 0)
goto failure; goto failure;
if (cfg->fc_oif && fi->fib_nh->nh_oif != cfg->fc_oif) if (cfg->fc_oif && fi->fib_nh->nh_oif != cfg->fc_oif)
...@@ -1129,7 +1131,9 @@ struct fib_info *fib_create_info(struct fib_config *cfg) ...@@ -1129,7 +1131,9 @@ struct fib_info *fib_create_info(struct fib_config *cfg)
struct fib_nh *nh = fi->fib_nh; struct fib_nh *nh = fi->fib_nh;
/* Local address is added. */ /* Local address is added. */
if (nhs != 1 || nh->nh_gw) if (nhs != 1)
goto err_inval;
if (nh->nh_gw)
goto err_inval; goto err_inval;
nh->nh_scope = RT_SCOPE_NOWHERE; nh->nh_scope = RT_SCOPE_NOWHERE;
nh->nh_dev = dev_get_by_index(net, fi->fib_nh->nh_oif); nh->nh_dev = dev_get_by_index(net, fi->fib_nh->nh_oif);
...@@ -1140,7 +1144,7 @@ struct fib_info *fib_create_info(struct fib_config *cfg) ...@@ -1140,7 +1144,7 @@ struct fib_info *fib_create_info(struct fib_config *cfg)
int linkdown = 0; int linkdown = 0;
change_nexthops(fi) { change_nexthops(fi) {
err = fib_check_nh(cfg, fi, nexthop_nh); err = fib_check_nh(cfg, fi, nexthop_nh, extack);
if (err != 0) if (err != 0)
goto failure; goto failure;
if (nexthop_nh->nh_flags & RTNH_F_LINKDOWN) if (nexthop_nh->nh_flags & RTNH_F_LINKDOWN)
......
...@@ -1101,7 +1101,7 @@ static int fib_insert_alias(struct trie *t, struct key_vector *tp, ...@@ -1101,7 +1101,7 @@ static int fib_insert_alias(struct trie *t, struct key_vector *tp,
/* Caller must hold RTNL. */ /* Caller must hold RTNL. */
int fib_table_insert(struct net *net, struct fib_table *tb, int fib_table_insert(struct net *net, struct fib_table *tb,
struct fib_config *cfg) struct fib_config *cfg, struct netlink_ext_ack *extack)
{ {
enum fib_event_type event = FIB_EVENT_ENTRY_ADD; enum fib_event_type event = FIB_EVENT_ENTRY_ADD;
struct trie *t = (struct trie *)tb->tb_data; struct trie *t = (struct trie *)tb->tb_data;
...@@ -1125,7 +1125,7 @@ int fib_table_insert(struct net *net, struct fib_table *tb, ...@@ -1125,7 +1125,7 @@ int fib_table_insert(struct net *net, struct fib_table *tb,
if ((plen < KEYLENGTH) && (key << plen)) if ((plen < KEYLENGTH) && (key << plen))
return -EINVAL; return -EINVAL;
fi = fib_create_info(cfg); fi = fib_create_info(cfg, extack);
if (IS_ERR(fi)) { if (IS_ERR(fi)) {
err = PTR_ERR(fi); err = PTR_ERR(fi);
goto err; goto err;
......
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