1// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause 2#include <linux/bpf.h> 3#include <bpf/bpf_helpers.h> 4#include <bpf/bpf_endian.h> 5 6char _license[] SEC("license") = "GPL"; 7 8int ifindex; 9int ret; 10 11SEC("lwt_xmit") 12int redirect_ingress(struct __sk_buff *skb) 13{ 14 ret = bpf_clone_redirect(skb, ifindex, BPF_F_INGRESS); 15 return 0; 16} 17 18SEC("lwt_xmit") 19int redirect_egress(struct __sk_buff *skb) 20{ 21 ret = bpf_clone_redirect(skb, ifindex, 0); 22 return 0; 23} 24 25SEC("tc") 26int tc_redirect_ingress(struct __sk_buff *skb) 27{ 28 ret = bpf_clone_redirect(skb, ifindex, BPF_F_INGRESS); 29 return 0; 30} 31 32SEC("tc") 33int tc_redirect_egress(struct __sk_buff *skb) 34{ 35 ret = bpf_clone_redirect(skb, ifindex, 0); 36 return 0; 37} 38