1 Index: linux-3.8.13/include/net/netns/ipv6.h
2 ===================================================================
3 --- linux-3.8.13.orig/include/net/netns/ipv6.h 2013-06-10 14:14:20.910911309 +0200
4 +++ linux-3.8.13/include/net/netns/ipv6.h 2013-06-10 14:14:20.898911309 +0200
6 unsigned long ip6_rt_last_gc;
7 #ifdef CONFIG_IPV6_MULTIPLE_TABLES
8 struct rt6_info *ip6_prohibit_entry;
9 + struct rt6_info *ip6_failed_policy_entry;
10 struct rt6_info *ip6_blk_hole_entry;
11 struct fib6_table *fib6_local_tbl;
12 struct fib_rules_ops *fib6_rules_ops;
13 Index: linux-3.8.13/include/uapi/linux/fib_rules.h
14 ===================================================================
15 --- linux-3.8.13.orig/include/uapi/linux/fib_rules.h 2013-06-10 14:14:20.910911309 +0200
16 +++ linux-3.8.13/include/uapi/linux/fib_rules.h 2013-06-10 14:14:20.898911309 +0200
18 FR_ACT_BLACKHOLE, /* Drop without notification */
19 FR_ACT_UNREACHABLE, /* Drop with ENETUNREACH */
20 FR_ACT_PROHIBIT, /* Drop with EACCES */
24 + FR_ACT_FAILED_POLICY, /* Drop with EPERM */
28 Index: linux-3.8.13/include/uapi/linux/icmpv6.h
29 ===================================================================
30 --- linux-3.8.13.orig/include/uapi/linux/icmpv6.h 2013-06-10 14:14:20.910911309 +0200
31 +++ linux-3.8.13/include/uapi/linux/icmpv6.h 2013-06-10 14:14:20.898911309 +0200
33 #define ICMPV6_NOT_NEIGHBOUR 2
34 #define ICMPV6_ADDR_UNREACH 3
35 #define ICMPV6_PORT_UNREACH 4
36 +#define ICMPV6_FAILED_POLICY 5
39 * Codes for Time Exceeded
40 Index: linux-3.8.13/include/uapi/linux/rtnetlink.h
41 ===================================================================
42 --- linux-3.8.13.orig/include/uapi/linux/rtnetlink.h 2013-06-10 14:14:20.910911309 +0200
43 +++ linux-3.8.13/include/uapi/linux/rtnetlink.h 2013-06-10 14:14:20.898911309 +0200
45 RTN_THROW, /* Not in this table */
46 RTN_NAT, /* Translate this address */
47 RTN_XRESOLVE, /* Use external resolver */
48 + RTN_FAILED_POLICY, /* Failed ingress/egress policy */
52 Index: linux-3.8.13/net/ipv4/fib_rules.c
53 ===================================================================
54 --- linux-3.8.13.orig/net/ipv4/fib_rules.c 2013-06-10 14:14:20.910911309 +0200
55 +++ linux-3.8.13/net/ipv4/fib_rules.c 2013-06-10 14:14:20.898911309 +0200
60 + case FR_ACT_FAILED_POLICY:
64 case FR_ACT_BLACKHOLE:
67 Index: linux-3.8.13/net/ipv4/fib_semantics.c
68 ===================================================================
69 --- linux-3.8.13.orig/net/ipv4/fib_semantics.c 2013-06-10 14:14:20.910911309 +0200
70 +++ linux-3.8.13/net/ipv4/fib_semantics.c 2013-06-10 14:14:20.898911309 +0200
73 .scope = RT_SCOPE_NOWHERE,
75 + [RTN_FAILED_POLICY] = {
77 + .scope = RT_SCOPE_UNIVERSE,
81 static void rt_fibinfo_free(struct rtable __rcu **rtp)
82 Index: linux-3.8.13/net/ipv4/fib_trie.c
83 ===================================================================
84 --- linux-3.8.13.orig/net/ipv4/fib_trie.c 2013-06-10 14:14:20.910911309 +0200
85 +++ linux-3.8.13/net/ipv4/fib_trie.c 2013-06-10 14:14:20.902911309 +0200
87 [RTN_THROW] = "THROW",
89 [RTN_XRESOLVE] = "XRESOLVE",
90 + [RTN_FAILED_POLICY] = "FAILED_POLICY",
93 static inline const char *rtn_type(char *buf, size_t len, unsigned int t)
94 Index: linux-3.8.13/net/ipv4/ipmr.c
95 ===================================================================
96 --- linux-3.8.13.orig/net/ipv4/ipmr.c 2013-06-10 14:14:20.910911309 +0200
97 +++ linux-3.8.13/net/ipv4/ipmr.c 2013-06-10 14:14:20.902911309 +0200
99 case FR_ACT_UNREACHABLE:
101 case FR_ACT_PROHIBIT:
102 + case FR_ACT_FAILED_POLICY:
104 case FR_ACT_BLACKHOLE:
106 Index: linux-3.8.13/net/ipv6/fib6_rules.c
107 ===================================================================
108 --- linux-3.8.13.orig/net/ipv6/fib6_rules.c 2013-06-10 14:14:20.910911309 +0200
109 +++ linux-3.8.13/net/ipv6/fib6_rules.c 2013-06-10 14:14:20.902911309 +0200
111 case FR_ACT_PROHIBIT:
112 rt = net->ipv6.ip6_prohibit_entry;
114 + case FR_ACT_FAILED_POLICY:
115 + rt = net->ipv6.ip6_failed_policy_entry;
119 table = fib6_get_table(net, rule->table);
120 Index: linux-3.8.13/net/ipv6/ip6mr.c
121 ===================================================================
122 --- linux-3.8.13.orig/net/ipv6/ip6mr.c 2013-06-10 14:14:20.910911309 +0200
123 +++ linux-3.8.13/net/ipv6/ip6mr.c 2013-06-10 14:14:20.902911309 +0200
126 case FR_ACT_PROHIBIT:
128 + case FR_ACT_FAILED_POLICY:
130 case FR_ACT_BLACKHOLE:
133 Index: linux-3.8.13/net/ipv6/route.c
134 ===================================================================
135 --- linux-3.8.13.orig/net/ipv6/route.c 2013-06-10 14:14:20.910911309 +0200
136 +++ linux-3.8.13/net/ipv6/route.c 2013-06-10 14:14:20.906911309 +0200
138 .rt6i_ref = ATOMIC_INIT(1),
141 +static int ip6_pkt_failed_policy(struct sk_buff *skb);
142 +static int ip6_pkt_failed_policy_out(struct sk_buff *skb);
144 +static const struct rt6_info ip6_failed_policy_entry_template = {
146 + .__refcnt = ATOMIC_INIT(1),
148 + .obsolete = DST_OBSOLETE_FORCE_CHK,
150 + .input = ip6_pkt_failed_policy,
151 + .output = ip6_pkt_failed_policy_out,
153 + .rt6i_flags = (RTF_REJECT | RTF_NONEXTHOP),
154 + .rt6i_protocol = RTPROT_KERNEL,
155 + .rt6i_metric = ~(u32) 0,
156 + .rt6i_ref = ATOMIC_INIT(1),
159 static const struct rt6_info ip6_blk_hole_entry_template = {
161 .__refcnt = ATOMIC_INIT(1),
162 @@ -1516,6 +1534,9 @@
164 rt->dst.error = -EAGAIN;
166 + case RTN_FAILED_POLICY:
167 + rt->dst.error = -EPERM;
170 rt->dst.error = -ENETUNREACH;
172 @@ -2110,6 +2131,17 @@
173 return ip6_pkt_drop(skb, ICMPV6_ADM_PROHIBITED, IPSTATS_MIB_OUTNOROUTES);
176 +static int ip6_pkt_failed_policy(struct sk_buff *skb)
178 + return ip6_pkt_drop(skb, ICMPV6_FAILED_POLICY, IPSTATS_MIB_INNOROUTES);
181 +static int ip6_pkt_failed_policy_out(struct sk_buff *skb)
183 + skb->dev = skb_dst(skb)->dev;
184 + return ip6_pkt_drop(skb, ICMPV6_FAILED_POLICY, IPSTATS_MIB_OUTNOROUTES);
190 @@ -2321,7 +2353,8 @@
191 if (rtm->rtm_type == RTN_UNREACHABLE ||
192 rtm->rtm_type == RTN_BLACKHOLE ||
193 rtm->rtm_type == RTN_PROHIBIT ||
194 - rtm->rtm_type == RTN_THROW)
195 + rtm->rtm_type == RTN_THROW ||
196 + rtm->rtm_type == RTN_FAILED_POLICY)
197 cfg->fc_flags |= RTF_REJECT;
199 if (rtm->rtm_type == RTN_LOCAL)
200 @@ -2524,6 +2557,9 @@
202 rtm->rtm_type = RTN_PROHIBIT;
205 + rtm->rtm_type = RTN_FAILED_POLICY;
208 rtm->rtm_type = RTN_THROW;
210 @@ -2775,6 +2811,8 @@
211 #ifdef CONFIG_IPV6_MULTIPLE_TABLES
212 net->ipv6.ip6_prohibit_entry->dst.dev = dev;
213 net->ipv6.ip6_prohibit_entry->rt6i_idev = in6_dev_get(dev);
214 + net->ipv6.ip6_failed_policy_entry->dst.dev = dev;
215 + net->ipv6.ip6_failed_policy_entry->rt6i_idev = in6_dev_get(dev);
216 net->ipv6.ip6_blk_hole_entry->dst.dev = dev;
217 net->ipv6.ip6_blk_hole_entry->rt6i_idev = in6_dev_get(dev);
219 @@ -3037,6 +3075,17 @@
220 net->ipv6.ip6_blk_hole_entry->dst.ops = &net->ipv6.ip6_dst_ops;
221 dst_init_metrics(&net->ipv6.ip6_blk_hole_entry->dst,
222 ip6_template_metrics, true);
224 + net->ipv6.ip6_failed_policy_entry =
225 + kmemdup(&ip6_failed_policy_entry_template,
226 + sizeof(*net->ipv6.ip6_failed_policy_entry), GFP_KERNEL);
227 + if (!net->ipv6.ip6_failed_policy_entry)
228 + goto out_ip6_blk_hole_entry;
229 + net->ipv6.ip6_failed_policy_entry->dst.path =
230 + (struct dst_entry *)net->ipv6.ip6_failed_policy_entry;
231 + net->ipv6.ip6_failed_policy_entry->dst.ops = &net->ipv6.ip6_dst_ops;
232 + dst_init_metrics(&net->ipv6.ip6_failed_policy_entry->dst,
233 + ip6_template_metrics, true);
236 net->ipv6.sysctl.flush_delay = 0;
237 @@ -3055,6 +3104,8 @@
240 #ifdef CONFIG_IPV6_MULTIPLE_TABLES
241 +out_ip6_blk_hole_entry:
242 + kfree(net->ipv6.ip6_blk_hole_entry);
243 out_ip6_prohibit_entry:
244 kfree(net->ipv6.ip6_prohibit_entry);
246 @@ -3072,6 +3123,7 @@
247 #ifdef CONFIG_IPV6_MULTIPLE_TABLES
248 kfree(net->ipv6.ip6_prohibit_entry);
249 kfree(net->ipv6.ip6_blk_hole_entry);
250 + kfree(net->ipv6.ip6_failed_policy_entry);
252 dst_entries_destroy(&net->ipv6.ip6_dst_ops);
254 @@ -3168,6 +3220,9 @@
255 init_net.ipv6.ip6_prohibit_entry->rt6i_idev = in6_dev_get(init_net.loopback_dev);
256 init_net.ipv6.ip6_blk_hole_entry->dst.dev = init_net.loopback_dev;
257 init_net.ipv6.ip6_blk_hole_entry->rt6i_idev = in6_dev_get(init_net.loopback_dev);
258 + init_net.ipv6.ip6_failed_policy_entry->dst.dev = init_net.loopback_dev;
259 + init_net.ipv6.ip6_failed_policy_entry->rt6i_idev =
260 + in6_dev_get(init_net.loopback_dev);