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