Commit 48b9b27a authored by David S. Miller's avatar David S. Miller Committed by David S. Miller

[IPV4]: FIB cleanup, rtmsg_fib()

Based largely upon a patch by Robert Olsson.

Abstract out rtmsg_fib() so that it does not depend
upon fib_hash internal datastructures, move it to
fib_semantics.c
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 1e69ba3f
...@@ -376,11 +376,6 @@ fn_hash_select_default(struct fib_table *tb, const struct flowi *flp, struct fib ...@@ -376,11 +376,6 @@ fn_hash_select_default(struct fib_table *tb, const struct flowi *flp, struct fib
read_unlock(&fib_hash_lock); read_unlock(&fib_hash_lock);
} }
static void rtmsg_fib(int, struct fib_node *, struct fib_alias *,
int, int,
struct nlmsghdr *n,
struct netlink_skb_parms *);
/* Insert node F to FZ. */ /* Insert node F to FZ. */
static inline void fib_insert_node(struct fn_zone *fz, struct fib_node *f) static inline void fib_insert_node(struct fn_zone *fz, struct fib_node *f)
{ {
...@@ -565,7 +560,7 @@ fn_hash_insert(struct fib_table *tb, struct rtmsg *r, struct kern_rta *rta, ...@@ -565,7 +560,7 @@ fn_hash_insert(struct fib_table *tb, struct rtmsg *r, struct kern_rta *rta,
fz->fz_nent++; fz->fz_nent++;
rt_cache_flush(-1); rt_cache_flush(-1);
rtmsg_fib(RTM_NEWROUTE, f, new_fa, z, tb->tb_id, n, req); rtmsg_fib(RTM_NEWROUTE, key, new_fa, z, tb->tb_id, n, req);
return 0; return 0;
out_free_new_fa: out_free_new_fa:
...@@ -631,7 +626,7 @@ fn_hash_delete(struct fib_table *tb, struct rtmsg *r, struct kern_rta *rta, ...@@ -631,7 +626,7 @@ fn_hash_delete(struct fib_table *tb, struct rtmsg *r, struct kern_rta *rta,
int kill_fn; int kill_fn;
fa = fa_to_delete; fa = fa_to_delete;
rtmsg_fib(RTM_DELROUTE, f, fa, z, tb->tb_id, n, req); rtmsg_fib(RTM_DELROUTE, key, fa, z, tb->tb_id, n, req);
kill_fn = 0; kill_fn = 0;
write_lock_bh(&fib_hash_lock); write_lock_bh(&fib_hash_lock);
...@@ -796,33 +791,6 @@ static int fn_hash_dump(struct fib_table *tb, struct sk_buff *skb, struct netlin ...@@ -796,33 +791,6 @@ static int fn_hash_dump(struct fib_table *tb, struct sk_buff *skb, struct netlin
return skb->len; return skb->len;
} }
static void rtmsg_fib(int event, struct fib_node *f, struct fib_alias *fa,
int z, int tb_id,
struct nlmsghdr *n, struct netlink_skb_parms *req)
{
struct sk_buff *skb;
u32 pid = req ? req->pid : 0;
int size = NLMSG_SPACE(sizeof(struct rtmsg)+256);
skb = alloc_skb(size, GFP_KERNEL);
if (!skb)
return;
if (fib_dump_info(skb, pid, n->nlmsg_seq, event, tb_id,
fa->fa_type, fa->fa_scope, &f->fn_key, z,
fa->fa_tos,
fa->fa_info) < 0) {
kfree_skb(skb);
return;
}
NETLINK_CB(skb).dst_groups = RTMGRP_IPV4_ROUTE;
if (n->nlmsg_flags&NLM_F_ECHO)
atomic_inc(&skb->users);
netlink_broadcast(rtnl, skb, pid, RTMGRP_IPV4_ROUTE, GFP_KERNEL);
if (n->nlmsg_flags&NLM_F_ECHO)
netlink_unicast(rtnl, skb, pid, MSG_DONTWAIT);
}
#ifdef CONFIG_IP_MULTIPLE_TABLES #ifdef CONFIG_IP_MULTIPLE_TABLES
struct fib_table * fib_hash_init(int id) struct fib_table * fib_hash_init(int id)
#else #else
......
...@@ -30,5 +30,8 @@ extern int fib_nh_match(struct rtmsg *r, struct nlmsghdr *, ...@@ -30,5 +30,8 @@ extern int fib_nh_match(struct rtmsg *r, struct nlmsghdr *,
extern int fib_dump_info(struct sk_buff *skb, u32 pid, u32 seq, int event, extern int fib_dump_info(struct sk_buff *skb, u32 pid, u32 seq, int event,
u8 tb_id, u8 type, u8 scope, void *dst, u8 tb_id, u8 type, u8 scope, void *dst,
int dst_len, u8 tos, struct fib_info *fi); int dst_len, u8 tos, struct fib_info *fi);
extern void rtmsg_fib(int event, u32 key, struct fib_alias *fa,
int z, int tb_id,
struct nlmsghdr *n, struct netlink_skb_parms *req);
#endif /* _FIB_LOOKUP_H */ #endif /* _FIB_LOOKUP_H */
...@@ -270,6 +270,33 @@ int ip_fib_check_default(u32 gw, struct net_device *dev) ...@@ -270,6 +270,33 @@ int ip_fib_check_default(u32 gw, struct net_device *dev)
return -1; return -1;
} }
void rtmsg_fib(int event, u32 key, struct fib_alias *fa,
int z, int tb_id,
struct nlmsghdr *n, struct netlink_skb_parms *req)
{
struct sk_buff *skb;
u32 pid = req ? req->pid : 0;
int size = NLMSG_SPACE(sizeof(struct rtmsg)+256);
skb = alloc_skb(size, GFP_KERNEL);
if (!skb)
return;
if (fib_dump_info(skb, pid, n->nlmsg_seq, event, tb_id,
fa->fa_type, fa->fa_scope, &key, z,
fa->fa_tos,
fa->fa_info) < 0) {
kfree_skb(skb);
return;
}
NETLINK_CB(skb).dst_groups = RTMGRP_IPV4_ROUTE;
if (n->nlmsg_flags&NLM_F_ECHO)
atomic_inc(&skb->users);
netlink_broadcast(rtnl, skb, pid, RTMGRP_IPV4_ROUTE, GFP_KERNEL);
if (n->nlmsg_flags&NLM_F_ECHO)
netlink_unicast(rtnl, skb, pid, MSG_DONTWAIT);
}
#ifdef CONFIG_IP_ROUTE_MULTIPATH #ifdef CONFIG_IP_ROUTE_MULTIPATH
static u32 fib_get_attr32(struct rtattr *attr, int attrlen, int type) static u32 fib_get_attr32(struct rtattr *attr, int attrlen, int type)
......
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