14 #include <linux/module.h>
25 #include <linux/netfilter/x_tables.h>
28 #if IS_ENABLED(CONFIG_NF_CONNTRACK)
29 # define WITH_CONNTRACK 1
48 return dev_net(skb->
dev);
51 return dev_net(dst->
dev);
59 const struct iphdr *iph = ip_hdr(skb);
60 struct net *
net = pick_net(skb);
64 memset(&fl4, 0,
sizeof(fl4));
66 if (info->priv->
oif == -1)
68 fl4.flowi4_oif = info->priv->
oif;
70 fl4.daddr = info->
gw.
ip;
74 rt = ip_route_output_key(net, &fl4);
79 skb_dst_set(skb, &rt->
dst);
103 #ifdef WITH_CONNTRACK
105 nf_conntrack_put(skb->nfct);
106 skb->nfct = &nf_ct_untracked_get()->ct_general;
108 nf_conntrack_get(skb->nfct);
127 if (tee_tg_route4(skb, info)) {
137 #if IS_ENABLED(CONFIG_IPV6)
141 const struct ipv6hdr *iph = ipv6_hdr(skb);
142 struct net *net = pick_net(skb);
146 memset(&fl6, 0,
sizeof(fl6));
148 if (info->priv->
oif == -1)
150 fl6.flowi6_oif = info->priv->
oif;
152 fl6.daddr = info->
gw.
in6;
153 fl6.flowlabel = ((iph->
flow_lbl[0] & 0xF) << 16) |
161 skb_dst_set(skb, dst);
178 #ifdef WITH_CONNTRACK
179 nf_conntrack_put(skb->nfct);
180 skb->nfct = &nf_ct_untracked_get()->ct_general;
182 nf_conntrack_get(skb->nfct);
186 struct ipv6hdr *iph = ipv6_hdr(skb);
189 if (tee_tg_route6(skb, info)) {
233 if (
memcmp(&info->
gw, &tee_zero_address,
234 sizeof(tee_zero_address)) == 0)
238 if (info->
oif[
sizeof(info->
oif)-1] !=
'\0')
247 priv->
notifier.notifier_call = tee_netdev_event;
274 .checkentry = tee_tg_check,
275 .destroy = tee_tg_destroy,
278 #if IS_ENABLED(CONFIG_IPV6)
285 .checkentry = tee_tg_check,
286 .destroy = tee_tg_destroy,
292 static int __init tee_tg_init(
void)
297 static void __exit tee_tg_exit(
void)