--- zzzz-none-000/linux-2.6.39.4/net/ipv6/route.c 2011-08-03 19:43:28.000000000 +0000 +++ puma6-arm-6490-729/linux-2.6.39.4/net/ipv6/route.c 2021-11-10 13:23:11.000000000 +0000 @@ -23,6 +23,11 @@ * Ville Nuorvala * Fixed routing subtrees. */ +/* + Includes Intel Corporation's changes/modifications dated: [Dec.2013]. + Changed/modified portions - Copyright © 2011, Intel Corporation + 1. PP Hook +*/ #include #include @@ -61,6 +66,10 @@ #include #endif +#ifdef CONFIG_TI_PACKET_PROCESSOR +#include +#endif + /* Set to 3 to get tracing. */ #define RT6_DEBUG 2 @@ -91,7 +100,7 @@ static struct rt6_info *rt6_add_route_info(struct net *net, struct in6_addr *prefix, int prefixlen, struct in6_addr *gwaddr, int ifindex, - unsigned pref); + u32 table, unsigned pref); static struct rt6_info *rt6_get_route_info(struct net *net, struct in6_addr *prefix, int prefixlen, struct in6_addr *gwaddr, int ifindex); @@ -319,7 +328,7 @@ if (dev->ifindex == oif) return sprt; if (dev->flags & IFF_LOOPBACK) { - if (sprt->rt6i_idev == NULL || + if (!sprt->rt6i_idev || sprt->rt6i_idev->dev->ifindex != oif) { if (flags & RT6_LOOKUP_F_IFACE && oif) continue; @@ -566,13 +575,20 @@ rt = NULL; } - if (!rt && lifetime) + if (!rt && lifetime) { + u32 table = RT6_TABLE_INFO; +#ifdef CONFIG_IPV6_MULTIPLE_TABLES + struct inet6_dev *idev; + if ((idev = __in6_dev_get(dev)) != NULL && + idev->cnf.ra_defrtr_table != RT6_TABLE_UNSPEC) + table = idev->cnf.ra_defrtr_table; +#endif rt = rt6_add_route_info(net, prefix, rinfo->prefix_len, gwaddr, dev->ifindex, - pref); - else if (rt) + table, pref); + } else if (rt) { rt->rt6i_flags = RTF_ROUTEINFO | (rt->rt6i_flags & ~RTF_PREF_MASK) | RTF_PREF(pref); - + } if (rt) { if (!addrconf_finite_timeout(lifetime)) { rt->rt6i_flags &= ~RTF_EXPIRES; @@ -1035,11 +1051,11 @@ struct inet6_dev *idev = in6_dev_get(dev); struct net *net = dev_net(dev); - if (unlikely(idev == NULL)) + if (unlikely(!idev)) return NULL; rt = ip6_dst_alloc(&net->ipv6.ip6_dst_ops); - if (unlikely(rt == NULL)) { + if (unlikely(!rt)) { in6_dev_put(idev); goto out; } @@ -1207,14 +1223,14 @@ cfg->fc_metric = IP6_RT_PRIO_USER; table = fib6_new_table(net, cfg->fc_table); - if (table == NULL) { + if (!table) { err = -ENOBUFS; goto out; } rt = ip6_dst_alloc(&net->ipv6.ip6_dst_ops); - if (rt == NULL) { + if (!rt) { err = -ENOMEM; goto out; } @@ -1303,7 +1319,7 @@ grt = rt6_lookup(net, gw_addr, NULL, cfg->fc_ifindex, 1); err = -EHOSTUNREACH; - if (grt == NULL) + if (!grt) goto out; if (dev) { if (dev != grt->rt6i_dev) { @@ -1324,12 +1340,12 @@ goto out; } err = -EINVAL; - if (dev == NULL || (dev->flags&IFF_LOOPBACK)) + if (!dev || (dev->flags&IFF_LOOPBACK)) goto out; } err = -ENODEV; - if (dev == NULL) + if (!dev) goto out; if (cfg->fc_flags & (RTF_GATEWAY | RTF_NONEXTHOP)) { @@ -1416,7 +1432,7 @@ int err = -ESRCH; table = fib6_get_table(cfg->fc_nlinfo.nl_net, cfg->fc_table); - if (table == NULL) + if (!table) return err; read_lock_bh(&table->tb6_lock); @@ -1428,7 +1444,7 @@ if (fn) { for (rt = fn->leaf; rt; rt = rt->dst.rt6_next) { if (cfg->fc_ifindex && - (rt->rt6i_dev == NULL || + (!rt->rt6i_dev || rt->rt6i_dev->ifindex != cfg->fc_ifindex)) continue; if (cfg->fc_flags & RTF_GATEWAY && @@ -1573,7 +1589,7 @@ goto out; nrt = ip6_rt_copy(rt); - if (nrt == NULL) + if (!nrt) goto out; nrt->rt6i_flags = RTF_GATEWAY|RTF_UP|RTF_DYNAMIC|RTF_CACHE; @@ -1615,7 +1631,7 @@ int allfrag = 0; again: rt = rt6_lookup(net, daddr, saddr, ifindex, 0); - if (rt == NULL) + if (!rt) return; if (rt6_check_expired(rt)) { @@ -1761,7 +1777,7 @@ struct fib6_table *table; table = fib6_get_table(net, RT6_TABLE_INFO); - if (table == NULL) + if (!table) return NULL; write_lock_bh(&table->tb6_lock); @@ -1787,10 +1803,11 @@ static struct rt6_info *rt6_add_route_info(struct net *net, struct in6_addr *prefix, int prefixlen, struct in6_addr *gwaddr, int ifindex, + u32 table, unsigned pref) { struct fib6_config cfg = { - .fc_table = RT6_TABLE_INFO, + .fc_table = table, .fc_metric = IP6_RT_PRIO_USER, .fc_ifindex = ifindex, .fc_dst_len = prefixlen, @@ -1818,9 +1835,18 @@ { struct rt6_info *rt; struct fib6_table *table; +#ifdef CONFIG_IPV6_MULTIPLE_TABLES + u32 dflt_table = RT6_TABLE_DFLT; + struct inet6_dev *idev; + if ((idev = __in6_dev_get(dev)) != NULL && + idev->cnf.ra_defrtr_table != RT6_TABLE_UNSPEC) + dflt_table = idev->cnf.ra_defrtr_table; + table = fib6_get_table(dev_net(dev), dflt_table); +#else table = fib6_get_table(dev_net(dev), RT6_TABLE_DFLT); - if (table == NULL) +#endif + if (!table) return NULL; write_lock_bh(&table->tb6_lock); @@ -1850,6 +1876,13 @@ .fc_nlinfo.nlh = NULL, .fc_nlinfo.nl_net = dev_net(dev), }; +#ifdef CONFIG_IPV6_MULTIPLE_TABLES + struct inet6_dev *idev; + + if ((idev = __in6_dev_get(dev)) != NULL && + idev->cnf.ra_defrtr_table != RT6_TABLE_UNSPEC) + cfg.fc_table = idev->cnf.ra_defrtr_table; +#endif ipv6_addr_copy(&cfg.fc_gateway, gwaddr); @@ -1858,6 +1891,22 @@ return rt6_get_dflt_router(gwaddr, dev); } +#ifdef CONFIG_IPV6_MULTIPLE_TABLES +static int fib6_dflt_router(struct rt6_info *rt, void *arg) +{ + if (rt->rt6i_flags & (RTF_DEFAULT | RTF_ADDRCONF)) { + dst_hold(&rt->dst); + RT6_TRACE("deleted by purge_dflt_routers %p\n", rt); + return -1; + } + return 0; +} + +void rt6_purge_dflt_routers(struct net *net) +{ + fib6_clean_all(net, fib6_dflt_router, 0, 0); +} +#else void rt6_purge_dflt_routers(struct net *net) { struct rt6_info *rt; @@ -1865,7 +1914,7 @@ /* NOTE: Keep consistent with rt6_get_dflt_router */ table = fib6_get_table(net, RT6_TABLE_DFLT); - if (table == NULL) + if (!table) return; restart: @@ -1880,6 +1929,7 @@ } read_unlock_bh(&table->tb6_lock); } +#endif static void rtmsg_to_fib6_config(struct net *net, struct in6_rtmsg *rtmsg, @@ -1968,7 +2018,14 @@ static int ip6_pkt_discard(struct sk_buff *skb) { - return ip6_pkt_drop(skb, ICMPV6_NOROUTE, IPSTATS_MIB_INNOROUTES); + int ret; +#ifdef CONFIG_TI_PACKET_PROCESSOR + /* Create a NULL PP device, to drop all dropped packets before they reach the host */ + ti_hil_pp_event (TI_IP_DISCARD_PKT_IPV6, (void *)skb); +#endif //CONFIG_TI_PACKET_PROCESSOR + /* "ip6_pkt_drop" include kfree_skb(skb), thats why we must do the PP event before that function - PP evevt use the skb pointer */ + ret = ip6_pkt_drop(skb, ICMPV6_NOROUTE, IPSTATS_MIB_INNOROUTES); + return ret; } static int ip6_pkt_discard_out(struct sk_buff *skb) @@ -2004,7 +2061,7 @@ struct rt6_info *rt = ip6_dst_alloc(&net->ipv6.ip6_dst_ops); struct neighbour *neigh; - if (rt == NULL) { + if (!rt) { if (net_ratelimit()) pr_warning("IPv6: Maximum number of routes reached," " consider increasing route/max_size.\n"); @@ -2053,7 +2110,7 @@ const struct arg_dev_net *adn = arg; const struct net_device *dev = adn->dev; - if ((rt->rt6i_dev == dev || dev == NULL) && + if ((rt->rt6i_dev == dev || !dev) && rt != adn->net->ipv6.ip6_null_entry) { RT6_TRACE("deleted by ifdown %p\n", rt); return -1; @@ -2090,7 +2147,7 @@ */ idev = __in6_dev_get(arg->dev); - if (idev == NULL) + if (!idev) return 0; /* For administrative MTU increase, there is no way to discover @@ -2266,7 +2323,7 @@ } nlh = nlmsg_put(skb, pid, seq, type, sizeof(*rtm), flags); - if (nlh == NULL) + if (!nlh) return -EMSGSIZE; rtm = nlmsg_data(nlh); @@ -2431,7 +2488,7 @@ } skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL); - if (skb == NULL) { + if (!skb) { err = -ENOBUFS; goto errout; } @@ -2469,7 +2526,7 @@ seq = info->nlh != NULL ? info->nlh->nlmsg_seq : 0; skb = nlmsg_new(rt6_nlmsg_size(), gfp_any()); - if (skb == NULL) + if (!skb) goto errout; err = rt6_fill_node(net, skb, rt, NULL, NULL, 0,