--- zzzz-none-000/linux-5.15.111/net/ipv6/route.c 2023-05-11 14:00:40.000000000 +0000 +++ puma7-arm-6670-761/linux-5.15.111/net/ipv6/route.c 2024-02-07 09:28:10.000000000 +0000 @@ -19,6 +19,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 +*/ #define pr_fmt(fmt) "IPv6: " fmt @@ -74,6 +79,9 @@ #include EXPORT_TRACEPOINT_SYMBOL_GPL(fib6_table_lookup); #undef CREATE_TRACE_POINTS +#ifdef CONFIG_TI_PACKET_PROCESSOR +#include +#endif enum rt6_nud_state { RT6_NUD_FAIL_HARD = -3, @@ -121,10 +129,17 @@ const struct in6_addr *gwaddr, struct net_device *dev, unsigned int pref); +static struct fib6_info *rt6_add_route_info_by_table(struct net *net, + const struct in6_addr *prefix, int prefixlen, + const struct in6_addr *gwaddr, int ifindex, + unsigned int pref, u32 table_id); static struct fib6_info *rt6_get_route_info(struct net *net, const struct in6_addr *prefix, int prefixlen, const struct in6_addr *gwaddr, struct net_device *dev); +static struct fib6_info *rt6_get_route_info_by_table(struct net *net, + const struct in6_addr *prefix, int prefixlen, + const struct in6_addr *gwaddr, int ifindex, u32 table_id); #endif struct uncached_list { @@ -924,6 +939,11 @@ int rt6_route_rcv(struct net_device *dev, u8 *opt, int len, const struct in6_addr *gwaddr) { + return rt6_route_rcv_by_table(dev, opt, len, gwaddr, RT6_TABLE_DFLT); +} +int rt6_route_rcv_by_table(struct net_device *dev, u8 *opt, int len, + const struct in6_addr *gwaddr, u32 table_id) +{ struct net *net = dev_net(dev); struct route_info *rinfo = (struct route_info *) opt; struct in6_addr prefix_buf, *prefix; @@ -967,10 +987,10 @@ } if (rinfo->prefix_len == 0) - rt = rt6_get_dflt_router(net, gwaddr, dev); + rt = rt6_get_dflt_router_by_table(net, gwaddr, dev, table_id); else - rt = rt6_get_route_info(net, prefix, rinfo->prefix_len, - gwaddr, dev); + rt = rt6_get_route_info_by_table(net, prefix, rinfo->prefix_len, + gwaddr, dev->ifindex, (table_id == RT6_TABLE_DFLT ? RT6_TABLE_INFO : table_id)); if (rt && !lifetime) { ip6_del_rt(net, rt, false); @@ -978,8 +998,8 @@ } if (!rt && lifetime) - rt = rt6_add_route_info(net, prefix, rinfo->prefix_len, gwaddr, - dev, pref); + rt = rt6_add_route_info_by_table(net, prefix, rinfo->prefix_len, gwaddr, dev->ifindex, + pref, table_id); else if (rt) rt->fib6_flags = RTF_ROUTEINFO | (rt->fib6_flags & ~RTF_PREF_MASK) | RTF_PREF(pref); @@ -4276,13 +4296,19 @@ const struct in6_addr *gwaddr, struct net_device *dev) { + return rt6_get_route_info_by_table(net, prefix, prefixlen, gwaddr, ifindex, RT6_TABLE_INFO); +} +static struct fib6_info *rt6_get_route_info_by_table(struct net *net, + const struct in6_addr *prefix, int prefixlen, + const struct in6_addr *gwaddr, int ifindex, u32 table_id) +{ u32 tb_id = l3mdev_fib_table(dev) ? : RT6_TABLE_INFO; int ifindex = dev->ifindex; struct fib6_node *fn; struct fib6_info *rt = NULL; struct fib6_table *table; - table = fib6_get_table(net, tb_id); + table = fib6_get_table(net, table_id); if (!table) return NULL; @@ -4317,7 +4343,15 @@ struct net_device *dev, unsigned int pref) { + return rt6_add_route_info_by_table(net, prefix, prefixlen, gwaddr, ifindex, pref, RT6_TABLE_INFO); +} +static struct rt6_info *rt6_add_route_info_by_table(struct net *net, + const struct in6_addr *prefix, int prefixlen, + const struct in6_addr *gwaddr, int ifindex, + unsigned int pref, u32 table_id) +{ struct fib6_config cfg = { + .fc_table = table_id, .fc_metric = IP6_RT_PRIO_USER, .fc_ifindex = dev->ifindex, .fc_dst_len = prefixlen, @@ -4340,7 +4374,7 @@ ip6_route_add(&cfg, GFP_ATOMIC, NULL); - return rt6_get_route_info(net, prefix, prefixlen, gwaddr, dev); + return rt6_get_route_info_by_table(net, prefix, prefixlen, gwaddr, ifindex, table_id); } #endif @@ -4348,11 +4382,16 @@ const struct in6_addr *addr, struct net_device *dev) { - u32 tb_id = l3mdev_fib_table(dev) ? : RT6_TABLE_DFLT; + return rt6_get_dflt_router_by_table(net, addr, dev, RT6_TABLE_DFLT); +} + +struct fib6_info *rt6_get_dflt_router_by_table(struct net *net, const struct in6_addr *addr, struct net_device *dev, u32 table_id) +{ struct fib6_info *rt; struct fib6_table *table; - table = fib6_get_table(net, tb_id); + table = fib6_get_table(net, table_id); + if (!table) return NULL; @@ -4382,8 +4421,15 @@ unsigned int pref, u32 defrtr_usr_metric) { + return rt6_add_dflt_router_by_table(net, gwaddr, dev, pref, defrtr_usr_metric, RT6_TABLE_DFLT); +} +struct fib6_info *rt6_add_dflt_router_by_table(struct net *net, + const struct in6_addr *gwaddr, + struct net_device *dev, + unsigned int pref, u32 defrtr_usr_metric, u32 table_id) +{ struct fib6_config cfg = { - .fc_table = l3mdev_fib_table(dev) ? : RT6_TABLE_DFLT, + .fc_table = table_id, .fc_metric = defrtr_usr_metric, .fc_ifindex = dev->ifindex, .fc_flags = RTF_GATEWAY | RTF_ADDRCONF | RTF_DEFAULT | @@ -4405,7 +4451,7 @@ table->flags |= RT6_TABLE_HAS_DFLT_ROUTER; } - return rt6_get_dflt_router(net, gwaddr, dev); + return rt6_get_dflt_router_by_table(net, gwaddr, dev, table_id); } static void __rt6_purge_dflt_routers(struct net *net, @@ -4540,7 +4586,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 net *net, struct sock *sk, struct sk_buff *skb)