route.c (eb5bc2a213f96bd43b5f00a625acb0c669613645) route.c (c78ba6d64c78634a875d1e316676667cabfea256)
1/*
2 * Linux INET6 implementation
3 * FIB front-end.
4 *
5 * Authors:
6 * Pedro Roque <roque@di.fc.ul.pt>
7 *
8 * This program is free software; you can redistribute it and/or

--- 180 unchanged lines hidden (view full) ---

189 n = __ipv6_neigh_lookup(dst->dev, daddr);
190 if (n)
191 return n;
192 return neigh_create(&nd_tbl, daddr, dst->dev);
193}
194
195static struct dst_ops ip6_dst_ops_template = {
196 .family = AF_INET6,
1/*
2 * Linux INET6 implementation
3 * FIB front-end.
4 *
5 * Authors:
6 * Pedro Roque <roque@di.fc.ul.pt>
7 *
8 * This program is free software; you can redistribute it and/or

--- 180 unchanged lines hidden (view full) ---

189 n = __ipv6_neigh_lookup(dst->dev, daddr);
190 if (n)
191 return n;
192 return neigh_create(&nd_tbl, daddr, dst->dev);
193}
194
195static struct dst_ops ip6_dst_ops_template = {
196 .family = AF_INET6,
197 .protocol = cpu_to_be16(ETH_P_IPV6),
198 .gc = ip6_dst_gc,
199 .gc_thresh = 1024,
200 .check = ip6_dst_check,
201 .default_advmss = ip6_default_advmss,
202 .mtu = ip6_mtu,
203 .cow_metrics = ipv6_cow_metrics,
204 .destroy = ip6_dst_destroy,
205 .ifdown = ip6_dst_ifdown,

--- 25 unchanged lines hidden (view full) ---

231static u32 *ip6_rt_blackhole_cow_metrics(struct dst_entry *dst,
232 unsigned long old)
233{
234 return NULL;
235}
236
237static struct dst_ops ip6_dst_blackhole_ops = {
238 .family = AF_INET6,
197 .gc = ip6_dst_gc,
198 .gc_thresh = 1024,
199 .check = ip6_dst_check,
200 .default_advmss = ip6_default_advmss,
201 .mtu = ip6_mtu,
202 .cow_metrics = ipv6_cow_metrics,
203 .destroy = ip6_dst_destroy,
204 .ifdown = ip6_dst_ifdown,

--- 25 unchanged lines hidden (view full) ---

230static u32 *ip6_rt_blackhole_cow_metrics(struct dst_entry *dst,
231 unsigned long old)
232{
233 return NULL;
234}
235
236static struct dst_ops ip6_dst_blackhole_ops = {
237 .family = AF_INET6,
239 .protocol = cpu_to_be16(ETH_P_IPV6),
240 .destroy = ip6_dst_destroy,
241 .check = ip6_dst_check,
242 .mtu = ip6_blackhole_mtu,
243 .default_advmss = ip6_default_advmss,
244 .update_pmtu = ip6_rt_blackhole_update_pmtu,
245 .redirect = ip6_rt_blackhole_redirect,
246 .cow_metrics = ip6_rt_blackhole_cow_metrics,
247 .neigh_lookup = ip6_neigh_lookup,

--- 2147 unchanged lines hidden (view full) ---

2395
2396static const struct nla_policy rtm_ipv6_policy[RTA_MAX+1] = {
2397 [RTA_GATEWAY] = { .len = sizeof(struct in6_addr) },
2398 [RTA_OIF] = { .type = NLA_U32 },
2399 [RTA_IIF] = { .type = NLA_U32 },
2400 [RTA_PRIORITY] = { .type = NLA_U32 },
2401 [RTA_METRICS] = { .type = NLA_NESTED },
2402 [RTA_MULTIPATH] = { .len = sizeof(struct rtnexthop) },
238 .destroy = ip6_dst_destroy,
239 .check = ip6_dst_check,
240 .mtu = ip6_blackhole_mtu,
241 .default_advmss = ip6_default_advmss,
242 .update_pmtu = ip6_rt_blackhole_update_pmtu,
243 .redirect = ip6_rt_blackhole_redirect,
244 .cow_metrics = ip6_rt_blackhole_cow_metrics,
245 .neigh_lookup = ip6_neigh_lookup,

--- 2147 unchanged lines hidden (view full) ---

2393
2394static const struct nla_policy rtm_ipv6_policy[RTA_MAX+1] = {
2395 [RTA_GATEWAY] = { .len = sizeof(struct in6_addr) },
2396 [RTA_OIF] = { .type = NLA_U32 },
2397 [RTA_IIF] = { .type = NLA_U32 },
2398 [RTA_PRIORITY] = { .type = NLA_U32 },
2399 [RTA_METRICS] = { .type = NLA_NESTED },
2400 [RTA_MULTIPATH] = { .len = sizeof(struct rtnexthop) },
2401 [RTA_PREF] = { .type = NLA_U8 },
2403};
2404
2405static int rtm_to_fib6_config(struct sk_buff *skb, struct nlmsghdr *nlh,
2406 struct fib6_config *cfg)
2407{
2408 struct rtmsg *rtm;
2409 struct nlattr *tb[RTA_MAX+1];
2402};
2403
2404static int rtm_to_fib6_config(struct sk_buff *skb, struct nlmsghdr *nlh,
2405 struct fib6_config *cfg)
2406{
2407 struct rtmsg *rtm;
2408 struct nlattr *tb[RTA_MAX+1];
2409 unsigned int pref;
2410 int err;
2411
2412 err = nlmsg_parse(nlh, sizeof(*rtm), tb, RTA_MAX, rtm_ipv6_policy);
2413 if (err < 0)
2414 goto errout;
2415
2416 err = -EINVAL;
2417 rtm = nlmsg_data(nlh);

--- 59 unchanged lines hidden (view full) ---

2477 if (tb[RTA_TABLE])
2478 cfg->fc_table = nla_get_u32(tb[RTA_TABLE]);
2479
2480 if (tb[RTA_MULTIPATH]) {
2481 cfg->fc_mp = nla_data(tb[RTA_MULTIPATH]);
2482 cfg->fc_mp_len = nla_len(tb[RTA_MULTIPATH]);
2483 }
2484
2410 int err;
2411
2412 err = nlmsg_parse(nlh, sizeof(*rtm), tb, RTA_MAX, rtm_ipv6_policy);
2413 if (err < 0)
2414 goto errout;
2415
2416 err = -EINVAL;
2417 rtm = nlmsg_data(nlh);

--- 59 unchanged lines hidden (view full) ---

2477 if (tb[RTA_TABLE])
2478 cfg->fc_table = nla_get_u32(tb[RTA_TABLE]);
2479
2480 if (tb[RTA_MULTIPATH]) {
2481 cfg->fc_mp = nla_data(tb[RTA_MULTIPATH]);
2482 cfg->fc_mp_len = nla_len(tb[RTA_MULTIPATH]);
2483 }
2484
2485 if (tb[RTA_PREF]) {
2486 pref = nla_get_u8(tb[RTA_PREF]);
2487 if (pref != ICMPV6_ROUTER_PREF_LOW &&
2488 pref != ICMPV6_ROUTER_PREF_HIGH)
2489 pref = ICMPV6_ROUTER_PREF_MEDIUM;
2490 cfg->fc_flags |= RTF_PREF(pref);
2491 }
2492
2485 err = 0;
2486errout:
2487 return err;
2488}
2489
2490static int ip6_route_multipath(struct fib6_config *cfg, int add)
2491{
2492 struct fib6_config r_cfg;

--- 87 unchanged lines hidden (view full) ---

2580 + nla_total_size(16) /* RTA_GATEWAY */
2581 + nla_total_size(16) /* RTA_PREFSRC */
2582 + nla_total_size(4) /* RTA_TABLE */
2583 + nla_total_size(4) /* RTA_IIF */
2584 + nla_total_size(4) /* RTA_OIF */
2585 + nla_total_size(4) /* RTA_PRIORITY */
2586 + RTAX_MAX * nla_total_size(4) /* RTA_METRICS */
2587 + nla_total_size(sizeof(struct rta_cacheinfo))
2493 err = 0;
2494errout:
2495 return err;
2496}
2497
2498static int ip6_route_multipath(struct fib6_config *cfg, int add)
2499{
2500 struct fib6_config r_cfg;

--- 87 unchanged lines hidden (view full) ---

2588 + nla_total_size(16) /* RTA_GATEWAY */
2589 + nla_total_size(16) /* RTA_PREFSRC */
2590 + nla_total_size(4) /* RTA_TABLE */
2591 + nla_total_size(4) /* RTA_IIF */
2592 + nla_total_size(4) /* RTA_OIF */
2593 + nla_total_size(4) /* RTA_PRIORITY */
2594 + RTAX_MAX * nla_total_size(4) /* RTA_METRICS */
2595 + nla_total_size(sizeof(struct rta_cacheinfo))
2588 + nla_total_size(TCP_CA_NAME_MAX); /* RTAX_CC_ALGO */
2596 + nla_total_size(TCP_CA_NAME_MAX) /* RTAX_CC_ALGO */
2597 + nla_total_size(1); /* RTA_PREF */
2589}
2590
2591static int rt6_fill_node(struct net *net,
2592 struct sk_buff *skb, struct rt6_info *rt,
2593 struct in6_addr *dst, struct in6_addr *src,
2594 int iif, int type, u32 portid, u32 seq,
2595 int prefix, int nowait, unsigned int flags)
2596{

--- 124 unchanged lines hidden (view full) ---

2721 if (nla_put_u32(skb, RTA_PRIORITY, rt->rt6i_metric))
2722 goto nla_put_failure;
2723
2724 expires = (rt->rt6i_flags & RTF_EXPIRES) ? rt->dst.expires - jiffies : 0;
2725
2726 if (rtnl_put_cacheinfo(skb, &rt->dst, 0, expires, rt->dst.error) < 0)
2727 goto nla_put_failure;
2728
2598}
2599
2600static int rt6_fill_node(struct net *net,
2601 struct sk_buff *skb, struct rt6_info *rt,
2602 struct in6_addr *dst, struct in6_addr *src,
2603 int iif, int type, u32 portid, u32 seq,
2604 int prefix, int nowait, unsigned int flags)
2605{

--- 124 unchanged lines hidden (view full) ---

2730 if (nla_put_u32(skb, RTA_PRIORITY, rt->rt6i_metric))
2731 goto nla_put_failure;
2732
2733 expires = (rt->rt6i_flags & RTF_EXPIRES) ? rt->dst.expires - jiffies : 0;
2734
2735 if (rtnl_put_cacheinfo(skb, &rt->dst, 0, expires, rt->dst.error) < 0)
2736 goto nla_put_failure;
2737
2738 if (nla_put_u8(skb, RTA_PREF, IPV6_EXTRACT_PREF(rt->rt6i_flags)))
2739 goto nla_put_failure;
2740
2729 nlmsg_end(skb, nlh);
2730 return 0;
2731
2732nla_put_failure:
2733 nlmsg_cancel(skb, nlh);
2734 return -EMSGSIZE;
2735}
2736

--- 558 unchanged lines hidden ---
2741 nlmsg_end(skb, nlh);
2742 return 0;
2743
2744nla_put_failure:
2745 nlmsg_cancel(skb, nlh);
2746 return -EMSGSIZE;
2747}
2748

--- 558 unchanged lines hidden ---