Commit 86872cb5 authored by Thomas Graf's avatar Thomas Graf Committed by David S. Miller

[IPv6] route: FIB6 configuration using struct fib6_config

Replaces the struct in6_rtmsg based interface orignating from
the ioctl interface with a struct fib6_config based on. Allows
changing the interface without breaking the ioctl interface
and avoids passing on tons of parameters.

The recently introduced struct nl_info is used to pass on
netlink authorship information for notifications.
Signed-off-by: default avatarThomas Graf <tgraf@suug.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 40e22e8f
...@@ -16,14 +16,35 @@ ...@@ -16,14 +16,35 @@
#ifdef __KERNEL__ #ifdef __KERNEL__
#include <linux/ipv6_route.h> #include <linux/ipv6_route.h>
#include <net/dst.h>
#include <net/flow.h>
#include <linux/rtnetlink.h> #include <linux/rtnetlink.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <net/dst.h>
#include <net/flow.h>
#include <net/netlink.h>
struct rt6_info; struct rt6_info;
struct fib6_config
{
u32 fc_table;
u32 fc_metric;
int fc_dst_len;
int fc_src_len;
int fc_ifindex;
u32 fc_flags;
u32 fc_protocol;
struct in6_addr fc_dst;
struct in6_addr fc_src;
struct in6_addr fc_gateway;
unsigned long fc_expires;
struct nlattr *fc_mx;
int fc_mx_len;
struct nl_info fc_nlinfo;
};
struct fib6_node struct fib6_node
{ {
struct fib6_node *parent; struct fib6_node *parent;
...@@ -175,18 +196,13 @@ extern void fib6_clean_all(int (*func)(struct rt6_info *, void *arg), ...@@ -175,18 +196,13 @@ extern void fib6_clean_all(int (*func)(struct rt6_info *, void *arg),
extern int fib6_add(struct fib6_node *root, extern int fib6_add(struct fib6_node *root,
struct rt6_info *rt, struct rt6_info *rt,
struct nlmsghdr *nlh, struct nl_info *info);
void *rtattr,
struct netlink_skb_parms *req);
extern int fib6_del(struct rt6_info *rt, extern int fib6_del(struct rt6_info *rt,
struct nlmsghdr *nlh, struct nl_info *info);
void *rtattr,
struct netlink_skb_parms *req);
extern void inet6_rt_notify(int event, struct rt6_info *rt, extern void inet6_rt_notify(int event, struct rt6_info *rt,
struct nlmsghdr *nlh, struct nl_info *info);
struct netlink_skb_parms *req);
extern void fib6_run_gc(unsigned long dummy); extern void fib6_run_gc(unsigned long dummy);
......
...@@ -60,11 +60,7 @@ extern void ip6_route_cleanup(void); ...@@ -60,11 +60,7 @@ extern void ip6_route_cleanup(void);
extern int ipv6_route_ioctl(unsigned int cmd, void __user *arg); extern int ipv6_route_ioctl(unsigned int cmd, void __user *arg);
extern int ip6_route_add(struct in6_rtmsg *rtmsg, extern int ip6_route_add(struct fib6_config *cfg);
struct nlmsghdr *,
void *rtattr,
struct netlink_skb_parms *req,
u32 table_id);
extern int ip6_ins_rt(struct rt6_info *); extern int ip6_ins_rt(struct rt6_info *);
extern int ip6_del_rt(struct rt6_info *); extern int ip6_del_rt(struct rt6_info *);
......
...@@ -1509,59 +1509,56 @@ static void ...@@ -1509,59 +1509,56 @@ static void
addrconf_prefix_route(struct in6_addr *pfx, int plen, struct net_device *dev, addrconf_prefix_route(struct in6_addr *pfx, int plen, struct net_device *dev,
unsigned long expires, u32 flags) unsigned long expires, u32 flags)
{ {
struct in6_rtmsg rtmsg; struct fib6_config cfg = {
.fc_table = RT6_TABLE_PREFIX,
.fc_metric = IP6_RT_PRIO_ADDRCONF,
.fc_ifindex = dev->ifindex,
.fc_expires = expires,
.fc_dst_len = plen,
.fc_flags = RTF_UP | flags,
};
memset(&rtmsg, 0, sizeof(rtmsg)); ipv6_addr_copy(&cfg.fc_dst, pfx);
ipv6_addr_copy(&rtmsg.rtmsg_dst, pfx);
rtmsg.rtmsg_dst_len = plen;
rtmsg.rtmsg_metric = IP6_RT_PRIO_ADDRCONF;
rtmsg.rtmsg_ifindex = dev->ifindex;
rtmsg.rtmsg_info = expires;
rtmsg.rtmsg_flags = RTF_UP|flags;
rtmsg.rtmsg_type = RTMSG_NEWROUTE;
/* Prevent useless cloning on PtP SIT. /* Prevent useless cloning on PtP SIT.
This thing is done here expecting that the whole This thing is done here expecting that the whole
class of non-broadcast devices need not cloning. class of non-broadcast devices need not cloning.
*/ */
if (dev->type == ARPHRD_SIT && (dev->flags&IFF_POINTOPOINT)) if (dev->type == ARPHRD_SIT && (dev->flags & IFF_POINTOPOINT))
rtmsg.rtmsg_flags |= RTF_NONEXTHOP; cfg.fc_flags |= RTF_NONEXTHOP;
ip6_route_add(&rtmsg, NULL, NULL, NULL, RT6_TABLE_PREFIX); ip6_route_add(&cfg);
} }
/* Create "default" multicast route to the interface */ /* Create "default" multicast route to the interface */
static void addrconf_add_mroute(struct net_device *dev) static void addrconf_add_mroute(struct net_device *dev)
{ {
struct in6_rtmsg rtmsg; struct fib6_config cfg = {
.fc_table = RT6_TABLE_LOCAL,
memset(&rtmsg, 0, sizeof(rtmsg)); .fc_metric = IP6_RT_PRIO_ADDRCONF,
ipv6_addr_set(&rtmsg.rtmsg_dst, .fc_ifindex = dev->ifindex,
htonl(0xFF000000), 0, 0, 0); .fc_dst_len = 8,
rtmsg.rtmsg_dst_len = 8; .fc_flags = RTF_UP,
rtmsg.rtmsg_metric = IP6_RT_PRIO_ADDRCONF; };
rtmsg.rtmsg_ifindex = dev->ifindex;
rtmsg.rtmsg_flags = RTF_UP; ipv6_addr_set(&cfg.fc_dst, htonl(0xFF000000), 0, 0, 0);
rtmsg.rtmsg_type = RTMSG_NEWROUTE;
ip6_route_add(&rtmsg, NULL, NULL, NULL, RT6_TABLE_LOCAL); ip6_route_add(&cfg);
} }
static void sit_route_add(struct net_device *dev) static void sit_route_add(struct net_device *dev)
{ {
struct in6_rtmsg rtmsg; struct fib6_config cfg = {
.fc_table = RT6_TABLE_MAIN,
memset(&rtmsg, 0, sizeof(rtmsg)); .fc_metric = IP6_RT_PRIO_ADDRCONF,
.fc_ifindex = dev->ifindex,
rtmsg.rtmsg_type = RTMSG_NEWROUTE; .fc_dst_len = 96,
rtmsg.rtmsg_metric = IP6_RT_PRIO_ADDRCONF; .fc_flags = RTF_UP | RTF_NONEXTHOP,
};
/* prefix length - 96 bits "::d.d.d.d" */ /* prefix length - 96 bits "::d.d.d.d" */
rtmsg.rtmsg_dst_len = 96; ip6_route_add(&cfg);
rtmsg.rtmsg_flags = RTF_UP|RTF_NONEXTHOP;
rtmsg.rtmsg_ifindex = dev->ifindex;
ip6_route_add(&rtmsg, NULL, NULL, NULL, RT6_TABLE_MAIN);
} }
static void addrconf_add_lroute(struct net_device *dev) static void addrconf_add_lroute(struct net_device *dev)
......
...@@ -610,7 +610,7 @@ static struct fib6_node * fib6_add_1(struct fib6_node *root, void *addr, ...@@ -610,7 +610,7 @@ static struct fib6_node * fib6_add_1(struct fib6_node *root, void *addr,
*/ */
static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt, static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt,
struct nlmsghdr *nlh, struct netlink_skb_parms *req) struct nl_info *info)
{ {
struct rt6_info *iter = NULL; struct rt6_info *iter = NULL;
struct rt6_info **ins; struct rt6_info **ins;
...@@ -665,7 +665,7 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt, ...@@ -665,7 +665,7 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt,
*ins = rt; *ins = rt;
rt->rt6i_node = fn; rt->rt6i_node = fn;
atomic_inc(&rt->rt6i_ref); atomic_inc(&rt->rt6i_ref);
inet6_rt_notify(RTM_NEWROUTE, rt, nlh, req); inet6_rt_notify(RTM_NEWROUTE, rt, info);
rt6_stats.fib_rt_entries++; rt6_stats.fib_rt_entries++;
if ((fn->fn_flags & RTN_RTINFO) == 0) { if ((fn->fn_flags & RTN_RTINFO) == 0) {
...@@ -695,8 +695,7 @@ void fib6_force_start_gc(void) ...@@ -695,8 +695,7 @@ void fib6_force_start_gc(void)
* with source addr info in sub-trees * with source addr info in sub-trees
*/ */
int fib6_add(struct fib6_node *root, struct rt6_info *rt, int fib6_add(struct fib6_node *root, struct rt6_info *rt, struct nl_info *info)
struct nlmsghdr *nlh, void *_rtattr, struct netlink_skb_parms *req)
{ {
struct fib6_node *fn; struct fib6_node *fn;
int err = -ENOMEM; int err = -ENOMEM;
...@@ -769,7 +768,7 @@ int fib6_add(struct fib6_node *root, struct rt6_info *rt, ...@@ -769,7 +768,7 @@ int fib6_add(struct fib6_node *root, struct rt6_info *rt,
} }
#endif #endif
err = fib6_add_rt2node(fn, rt, nlh, req); err = fib6_add_rt2node(fn, rt, info);
if (err == 0) { if (err == 0) {
fib6_start_gc(rt); fib6_start_gc(rt);
...@@ -1076,7 +1075,7 @@ static struct fib6_node * fib6_repair_tree(struct fib6_node *fn) ...@@ -1076,7 +1075,7 @@ static struct fib6_node * fib6_repair_tree(struct fib6_node *fn)
} }
static void fib6_del_route(struct fib6_node *fn, struct rt6_info **rtp, static void fib6_del_route(struct fib6_node *fn, struct rt6_info **rtp,
struct nlmsghdr *nlh, void *_rtattr, struct netlink_skb_parms *req) struct nl_info *info)
{ {
struct fib6_walker_t *w; struct fib6_walker_t *w;
struct rt6_info *rt = *rtp; struct rt6_info *rt = *rtp;
...@@ -1132,11 +1131,11 @@ static void fib6_del_route(struct fib6_node *fn, struct rt6_info **rtp, ...@@ -1132,11 +1131,11 @@ static void fib6_del_route(struct fib6_node *fn, struct rt6_info **rtp,
if (atomic_read(&rt->rt6i_ref) != 1) BUG(); if (atomic_read(&rt->rt6i_ref) != 1) BUG();
} }
inet6_rt_notify(RTM_DELROUTE, rt, nlh, req); inet6_rt_notify(RTM_DELROUTE, rt, info);
rt6_release(rt); rt6_release(rt);
} }
int fib6_del(struct rt6_info *rt, struct nlmsghdr *nlh, void *_rtattr, struct netlink_skb_parms *req) int fib6_del(struct rt6_info *rt, struct nl_info *info)
{ {
struct fib6_node *fn = rt->rt6i_node; struct fib6_node *fn = rt->rt6i_node;
struct rt6_info **rtp; struct rt6_info **rtp;
...@@ -1161,7 +1160,7 @@ int fib6_del(struct rt6_info *rt, struct nlmsghdr *nlh, void *_rtattr, struct ne ...@@ -1161,7 +1160,7 @@ int fib6_del(struct rt6_info *rt, struct nlmsghdr *nlh, void *_rtattr, struct ne
for (rtp = &fn->leaf; *rtp; rtp = &(*rtp)->u.next) { for (rtp = &fn->leaf; *rtp; rtp = &(*rtp)->u.next) {
if (*rtp == rt) { if (*rtp == rt) {
fib6_del_route(fn, rtp, nlh, _rtattr, req); fib6_del_route(fn, rtp, info);
return 0; return 0;
} }
} }
...@@ -1290,7 +1289,7 @@ static int fib6_clean_node(struct fib6_walker_t *w) ...@@ -1290,7 +1289,7 @@ static int fib6_clean_node(struct fib6_walker_t *w)
res = c->func(rt, c->arg); res = c->func(rt, c->arg);
if (res < 0) { if (res < 0) {
w->leaf = rt; w->leaf = rt;
res = fib6_del(rt, NULL, NULL, NULL); res = fib6_del(rt, NULL);
if (res) { if (res) {
#if RT6_DEBUG >= 2 #if RT6_DEBUG >= 2
printk(KERN_DEBUG "fib6_clean_node: del failed: rt=%p@%p err=%d\n", rt, rt->rt6i_node, res); printk(KERN_DEBUG "fib6_clean_node: del failed: rt=%p@%p err=%d\n", rt, rt->rt6i_node, res);
......
This diff is collapsed.
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