aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/ip_output.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv4/ip_output.c')
-rw-r--r--net/ipv4/ip_output.c34
1 files changed, 23 insertions, 11 deletions
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index d8f2a22c6ff7..ceca5285d9b4 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -287,16 +287,9 @@ static int ip_finish_output_gso(struct net *net, struct sock *sk,
287 return ret; 287 return ret;
288} 288}
289 289
290static int ip_finish_output(struct net *net, struct sock *sk, struct sk_buff *skb) 290static int __ip_finish_output(struct net *net, struct sock *sk, struct sk_buff *skb)
291{ 291{
292 unsigned int mtu; 292 unsigned int mtu;
293 int ret;
294
295 ret = BPF_CGROUP_RUN_PROG_INET_EGRESS(sk, skb);
296 if (ret) {
297 kfree_skb(skb);
298 return ret;
299 }
300 293
301#if defined(CONFIG_NETFILTER) && defined(CONFIG_XFRM) 294#if defined(CONFIG_NETFILTER) && defined(CONFIG_XFRM)
302 /* Policy lookup after SNAT yielded a new policy */ 295 /* Policy lookup after SNAT yielded a new policy */
@@ -315,18 +308,37 @@ static int ip_finish_output(struct net *net, struct sock *sk, struct sk_buff *sk
315 return ip_finish_output2(net, sk, skb); 308 return ip_finish_output2(net, sk, skb);
316} 309}
317 310
311static int ip_finish_output(struct net *net, struct sock *sk, struct sk_buff *skb)
312{
313 int ret;
314
315 ret = BPF_CGROUP_RUN_PROG_INET_EGRESS(sk, skb);
316 switch (ret) {
317 case NET_XMIT_SUCCESS:
318 return __ip_finish_output(net, sk, skb);
319 case NET_XMIT_CN:
320 return __ip_finish_output(net, sk, skb) ? : ret;
321 default:
322 kfree_skb(skb);
323 return ret;
324 }
325}
326
318static int ip_mc_finish_output(struct net *net, struct sock *sk, 327static int ip_mc_finish_output(struct net *net, struct sock *sk,
319 struct sk_buff *skb) 328 struct sk_buff *skb)
320{ 329{
321 int ret; 330 int ret;
322 331
323 ret = BPF_CGROUP_RUN_PROG_INET_EGRESS(sk, skb); 332 ret = BPF_CGROUP_RUN_PROG_INET_EGRESS(sk, skb);
324 if (ret) { 333 switch (ret) {
334 case NET_XMIT_SUCCESS:
335 return dev_loopback_xmit(net, sk, skb);
336 case NET_XMIT_CN:
337 return dev_loopback_xmit(net, sk, skb) ? : ret;
338 default:
325 kfree_skb(skb); 339 kfree_skb(skb);
326 return ret; 340 return ret;
327 } 341 }
328
329 return dev_loopback_xmit(net, sk, skb);
330} 342}
331 343
332int ip_mc_output(struct net *net, struct sock *sk, struct sk_buff *skb) 344int ip_mc_output(struct net *net, struct sock *sk, struct sk_buff *skb)