| 1 |
/* { dg-require-effective-target indirect_calls } */ |
| 2 |
/* { dg-additional-options "-fpermissive" } */ |
| 3 |
|
| 4 |
typedef unsigned char __u8; |
| 5 |
typedef unsigned short __u16; |
| 6 |
typedef unsigned int __u32; |
| 7 |
typedef unsigned long __kernel_size_t; |
| 8 |
typedef __kernel_size_t size_t; |
| 9 |
typedef __u8 uint8_t; |
| 10 |
typedef __u16 __be16; |
| 11 |
typedef __u32 __be32; |
| 12 |
struct msghdr { |
| 13 |
struct iovec * msg_iov; |
| 14 |
unsigned msg_flags; |
| 15 |
}; |
| 16 |
enum { IPPROTO_ICMP = 1 }; |
| 17 |
struct sk_buff { }; |
| 18 |
static inline __attribute__((always_inline)) struct dst_entry * |
| 19 |
skb_dst(const struct sk_buff *skb) |
| 20 |
{ |
| 21 |
}; |
| 22 |
enum nf_inet_hooks { NF_INET_LOCAL_OUT }; |
| 23 |
struct net_device { |
| 24 |
unsigned mtu; |
| 25 |
}; |
| 26 |
static inline __attribute__((always_inline)) int |
| 27 |
NF_HOOK_THRESH(uint8_t pf, unsigned int hook, struct sk_buff *skb, |
| 28 |
struct net_device *in, struct net_device *out, |
| 29 |
int (*okfn)(struct sk_buff *), int thresh) |
| 30 |
{ |
| 31 |
int ret = nf_hook_thresh(pf, hook, skb, in, out, okfn, thresh); |
| 32 |
if (ret == 1) |
| 33 |
ret = okfn(skb); |
| 34 |
return ret; |
| 35 |
} |
| 36 |
static inline __attribute__((always_inline)) int |
| 37 |
NF_HOOK(uint8_t pf, unsigned int hook, struct sk_buff *skb, |
| 38 |
struct net_device *in, struct net_device *out, |
| 39 |
int (*okfn)(struct sk_buff *)) |
| 40 |
{ |
| 41 |
return NF_HOOK_THRESH(pf, hook, skb, in, out, okfn, (-((int)(~0U>>1)) - 1)); |
| 42 |
} |
| 43 |
struct dst_entry { |
| 44 |
struct net_device *dev; |
| 45 |
int (*output)(struct sk_buff*); |
| 46 |
}; |
| 47 |
static inline __attribute__((always_inline)) int dst_output(struct sk_buff *skb) { |
| 48 |
return skb_dst(skb)->output(skb); |
| 49 |
}; |
| 50 |
struct iphdr { |
| 51 |
__u8 protocol; |
| 52 |
}; |
| 53 |
struct inet_sock { |
| 54 |
__be16 inet_dport; |
| 55 |
__u8 recverr: 1, hdrincl: 1; |
| 56 |
struct { } cork; |
| 57 |
}; |
| 58 |
struct icmphdr { |
| 59 |
__u8 type; |
| 60 |
}; |
| 61 |
struct rtable { |
| 62 |
union { struct dst_entry dst; } u; |
| 63 |
__be32 rt_dst; |
| 64 |
}; |
| 65 |
struct sock; |
| 66 |
struct inet_sock *inet_sk (struct sock *); |
| 67 |
struct net *sock_net (struct sock *); |
| 68 |
void *skb_transport_header (struct sk_buff *); |
| 69 |
static int raw_send_hdrinc(struct sock *sk, void *from, size_t length, |
| 70 |
struct rtable *rt, unsigned int flags) |
| 71 |
{ |
| 72 |
struct inet_sock *inet = inet_sk(sk); |
| 73 |
struct net *net = sock_net(sk); |
| 74 |
struct iphdr *iph; |
| 75 |
struct sk_buff *skb; |
| 76 |
if (length > rt->u.dst.dev->mtu) |
| 77 |
ip_local_error(sk, 90, rt->rt_dst, inet->inet_dport, rt->u.dst.dev->mtu); |
| 78 |
if (flags&0x10) |
| 79 |
goto out; |
| 80 |
if (iph->protocol == IPPROTO_ICMP) |
| 81 |
icmp_out_count(net, ((struct icmphdr *)skb_transport_header(skb))->type); |
| 82 |
NF_HOOK(2, NF_INET_LOCAL_OUT, skb, ((void *)0), rt->u.dst.dev, |
| 83 |
dst_output); |
| 84 |
out: |
| 85 |
while (0); |
| 86 |
} |
| 87 |
int raw_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) |
| 88 |
{ |
| 89 |
raw_send_hdrinc(sk, msg->msg_iov, len, (void *)0, msg->msg_flags); |
| 90 |
} |