X-Git-Url: http://pilppa.org/gitweb/?a=blobdiff_plain;f=net%2Fipv4%2Ffib_frontend.c;h=953dd458c23979cc68aef88e387a101e7b271be2;hb=4ac02bab77438b484a5cf855a002fb6a1d592894;hp=af0190d8b6c02ebdb2df31a96b2df8f4e67ddf1b;hpb=7b7fc708b568a258595e1fa911b930a75ac07b48;p=linux-2.6-omap-h63xx.git diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c index af0190d8b6c..953dd458c23 100644 --- a/net/ipv4/fib_frontend.c +++ b/net/ipv4/fib_frontend.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include @@ -35,7 +34,6 @@ #include #include #include -#include #include #include @@ -47,6 +45,7 @@ #include #include #include +#include #define FFprint(a...) printk(KERN_DEBUG a) @@ -160,7 +159,7 @@ unsigned inet_addr_type(__be32 addr) #ifdef CONFIG_IP_MULTIPLE_TABLES res.r = NULL; #endif - + if (ip_fib_local_table) { ret = RTN_UNICAST; if (!ip_fib_local_table->tb_lookup(ip_fib_local_table, @@ -378,7 +377,7 @@ static int rtentry_to_fib_config(int cmd, struct rtentry *rt, int len = 0; mx = kzalloc(3 * nla_total_size(4), GFP_KERNEL); - if (mx == NULL) + if (mx == NULL) return -ENOMEM; if (rt->rt_flags & RTF_MTU) @@ -400,7 +399,7 @@ static int rtentry_to_fib_config(int cmd, struct rtentry *rt, /* * Handle IP routing ioctl calls. These are used to manipulate the routing tables */ - + int ip_rt_ioctl(unsigned int cmd, void __user *arg) { struct fib_config cfg; @@ -494,6 +493,11 @@ static int rtm_to_fib_config(struct sk_buff *skb, struct nlmsghdr *nlh, cfg->fc_nlinfo.pid = NETLINK_CB(skb).pid; cfg->fc_nlinfo.nlh = nlh; + if (cfg->fc_type > RTN_MAX) { + err = -EINVAL; + goto errout; + } + nlmsg_for_each_attr(attr, nlh, sizeof(struct rtmsg), remaining) { switch (attr->nla_type) { case RTA_DST: @@ -536,7 +540,7 @@ errout: return err; } -int inet_rtm_delroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg) +static int inet_rtm_delroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg) { struct fib_config cfg; struct fib_table *tb; @@ -557,7 +561,7 @@ errout: return err; } -int inet_rtm_newroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg) +static int inet_rtm_newroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg) { struct fib_config cfg; struct fib_table *tb; @@ -578,7 +582,7 @@ errout: return err; } -int inet_dump_fib(struct sk_buff *skb, struct netlink_callback *cb) +static int inet_dump_fib(struct sk_buff *skb, struct netlink_callback *cb) { unsigned int h, s_h; unsigned int e = 0, s_e; @@ -600,7 +604,7 @@ int inet_dump_fib(struct sk_buff *skb, struct netlink_callback *cb) goto next; if (dumped) memset(&cb->args[2], 0, sizeof(cb->args) - - 2 * sizeof(cb->args[0])); + 2 * sizeof(cb->args[0])); if (tb->tb_dump(tb, skb, cb) < 0) goto out; dumped = 1; @@ -766,12 +770,14 @@ static void fib_del_ifaddr(struct in_ifaddr *ifa) static void nl_fib_lookup(struct fib_result_nl *frn, struct fib_table *tb ) { - + struct fib_result res; - struct flowi fl = { .nl_u = { .ip4_u = { .daddr = frn->fl_addr, - .fwmark = frn->fl_fwmark, + struct flowi fl = { .mark = frn->fl_mark, + .nl_u = { .ip4_u = { .daddr = frn->fl_addr, .tos = frn->fl_tos, .scope = frn->fl_scope } } }; + + frn->err = -ENOENT; if (tb) { local_bh_disable(); @@ -783,6 +789,7 @@ static void nl_fib_lookup(struct fib_result_nl *frn, struct fib_table *tb ) frn->nh_sel = res.nh_sel; frn->type = res.type; frn->scope = res.scope; + fib_res_put(&res); } local_bh_enable(); } @@ -791,34 +798,37 @@ static void nl_fib_lookup(struct fib_result_nl *frn, struct fib_table *tb ) static void nl_fib_input(struct sock *sk, int len) { struct sk_buff *skb = NULL; - struct nlmsghdr *nlh = NULL; + struct nlmsghdr *nlh = NULL; struct fib_result_nl *frn; - u32 pid; + u32 pid; struct fib_table *tb; - + skb = skb_dequeue(&sk->sk_receive_queue); - nlh = (struct nlmsghdr *)skb->data; + if (skb == NULL) + return; + + nlh = nlmsg_hdr(skb); if (skb->len < NLMSG_SPACE(0) || skb->len < nlh->nlmsg_len || nlh->nlmsg_len < NLMSG_LENGTH(sizeof(*frn))) { kfree_skb(skb); return; } - + frn = (struct fib_result_nl *) NLMSG_DATA(nlh); tb = fib_get_table(frn->tb_id_in); nl_fib_lookup(frn, tb); - - pid = nlh->nlmsg_pid; /*pid of sending process */ + + pid = NETLINK_CB(skb).pid; /* pid of sending process */ NETLINK_CB(skb).pid = 0; /* from kernel */ - NETLINK_CB(skb).dst_pid = pid; NETLINK_CB(skb).dst_group = 0; /* unicast */ netlink_unicast(sk, skb, pid, MSG_DONTWAIT); -} +} static void nl_fib_lookup_init(void) { - netlink_kernel_create(NETLINK_FIB_LOOKUP, 0, nl_fib_input, THIS_MODULE); + netlink_kernel_create(NETLINK_FIB_LOOKUP, 0, nl_fib_input, NULL, + THIS_MODULE); } static void fib_disable_ip(struct net_device *dev, int force) @@ -916,6 +926,10 @@ void __init ip_fib_init(void) register_netdevice_notifier(&fib_netdev_notifier); register_inetaddr_notifier(&fib_inetaddr_notifier); nl_fib_lookup_init(); + + rtnl_register(PF_INET, RTM_NEWROUTE, inet_rtm_newroute, NULL); + rtnl_register(PF_INET, RTM_DELROUTE, inet_rtm_delroute, NULL); + rtnl_register(PF_INET, RTM_GETROUTE, NULL, inet_dump_fib); } EXPORT_SYMBOL(inet_addr_type);