#ifndef _IP_H
#define _IP_H
#include <linux/types.h>
#include <linux/ip.h>
#include <linux/in.h>
#include <linux/skbuff.h>
#include <linux/jhash.h>
#include <linux/sockptr.h>
#include <linux/static_key.h>
#include <net/inet_sock.h>
#include <net/route.h>
#include <net/snmp.h>
#include <net/flow.h>
#include <net/flow_dissector.h>
#include <net/netns/hash.h>
#include <net/lwtunnel.h>
#define IPV4_MAX_PMTU …
#define IPV4_MIN_MTU …
extern unsigned int sysctl_fib_sync_mem;
extern unsigned int sysctl_fib_sync_mem_min;
extern unsigned int sysctl_fib_sync_mem_max;
struct sock;
struct inet_skb_parm { … };
static inline bool ipv4_l3mdev_skb(u16 flags)
{ … }
static inline unsigned int ip_hdrlen(const struct sk_buff *skb)
{ … }
struct ipcm_cookie { … };
static inline void ipcm_init(struct ipcm_cookie *ipcm)
{ … }
static inline void ipcm_init_sk(struct ipcm_cookie *ipcm,
const struct inet_sock *inet)
{ … }
#define IPCB(skb) …
#define PKTINFO_SKB_CB(skb) …
static inline int inet_sdif(const struct sk_buff *skb)
{ … }
struct ip_ra_chain { … };
#define IP_CE …
#define IP_DF …
#define IP_MF …
#define IP_OFFSET …
#define IP_FRAG_TIME …
struct msghdr;
struct net_device;
struct packet_type;
struct rtable;
struct sockaddr;
int igmp_mc_init(void);
int ip_build_and_send_pkt(struct sk_buff *skb, const struct sock *sk,
__be32 saddr, __be32 daddr,
struct ip_options_rcu *opt, u8 tos);
int ip_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt,
struct net_device *orig_dev);
void ip_list_rcv(struct list_head *head, struct packet_type *pt,
struct net_device *orig_dev);
int ip_local_deliver(struct sk_buff *skb);
void ip_protocol_deliver_rcu(struct net *net, struct sk_buff *skb, int proto);
int ip_mr_input(struct sk_buff *skb);
int ip_output(struct net *net, struct sock *sk, struct sk_buff *skb);
int ip_mc_output(struct net *net, struct sock *sk, struct sk_buff *skb);
int ip_do_fragment(struct net *net, struct sock *sk, struct sk_buff *skb,
int (*output)(struct net *, struct sock *, struct sk_buff *));
struct ip_fraglist_iter { … };
void ip_fraglist_init(struct sk_buff *skb, struct iphdr *iph,
unsigned int hlen, struct ip_fraglist_iter *iter);
void ip_fraglist_prepare(struct sk_buff *skb, struct ip_fraglist_iter *iter);
static inline struct sk_buff *ip_fraglist_next(struct ip_fraglist_iter *iter)
{ … }
struct ip_frag_state { … };
void ip_frag_init(struct sk_buff *skb, unsigned int hlen, unsigned int ll_rs,
unsigned int mtu, bool DF, struct ip_frag_state *state);
struct sk_buff *ip_frag_next(struct sk_buff *skb,
struct ip_frag_state *state);
void ip_send_check(struct iphdr *ip);
int __ip_local_out(struct net *net, struct sock *sk, struct sk_buff *skb);
int ip_local_out(struct net *net, struct sock *sk, struct sk_buff *skb);
int __ip_queue_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl,
__u8 tos);
void ip_init(void);
int ip_append_data(struct sock *sk, struct flowi4 *fl4,
int getfrag(void *from, char *to, int offset, int len,
int odd, struct sk_buff *skb),
void *from, int len, int protolen,
struct ipcm_cookie *ipc,
struct rtable **rt,
unsigned int flags);
int ip_generic_getfrag(void *from, char *to, int offset, int len, int odd,
struct sk_buff *skb);
struct sk_buff *__ip_make_skb(struct sock *sk, struct flowi4 *fl4,
struct sk_buff_head *queue,
struct inet_cork *cork);
int ip_send_skb(struct net *net, struct sk_buff *skb);
int ip_push_pending_frames(struct sock *sk, struct flowi4 *fl4);
void ip_flush_pending_frames(struct sock *sk);
struct sk_buff *ip_make_skb(struct sock *sk, struct flowi4 *fl4,
int getfrag(void *from, char *to, int offset,
int len, int odd, struct sk_buff *skb),
void *from, int length, int transhdrlen,
struct ipcm_cookie *ipc, struct rtable **rtp,
struct inet_cork *cork, unsigned int flags);
int ip_queue_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl);
static inline struct sk_buff *ip_finish_skb(struct sock *sk, struct flowi4 *fl4)
{ … }
static inline u8 ip_sendmsg_scope(const struct inet_sock *inet,
const struct ipcm_cookie *ipc,
const struct msghdr *msg)
{ … }
static inline __u8 get_rttos(struct ipcm_cookie* ipc, struct inet_sock *inet)
{ … }
int __ip4_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len);
int ip4_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len);
void ip4_datagram_release_cb(struct sock *sk);
struct ip_reply_arg { … };
#define IP_REPLY_ARG_NOSRCCHECK …
static inline __u8 ip_reply_arg_flowi_flags(const struct ip_reply_arg *arg)
{ … }
void ip_send_unicast_reply(struct sock *sk, struct sk_buff *skb,
const struct ip_options *sopt,
__be32 daddr, __be32 saddr,
const struct ip_reply_arg *arg,
unsigned int len, u64 transmit_time, u32 txhash);
#define IP_INC_STATS(net, field) …
#define __IP_INC_STATS(net, field) …
#define IP_ADD_STATS(net, field, val) …
#define __IP_ADD_STATS(net, field, val) …
#define IP_UPD_PO_STATS(net, field, val) …
#define __IP_UPD_PO_STATS(net, field, val) …
#define NET_INC_STATS(net, field) …
#define __NET_INC_STATS(net, field) …
#define NET_ADD_STATS(net, field, adnd) …
#define __NET_ADD_STATS(net, field, adnd) …
static inline u64 snmp_get_cpu_field(void __percpu *mib, int cpu, int offt)
{ … }
unsigned long snmp_fold_field(void __percpu *mib, int offt);
#if BITS_PER_LONG==32
u64 snmp_get_cpu_field64(void __percpu *mib, int cpu, int offct,
size_t syncp_offset);
u64 snmp_fold_field64(void __percpu *mib, int offt, size_t sync_off);
#else
static inline u64 snmp_get_cpu_field64(void __percpu *mib, int cpu, int offct,
size_t syncp_offset)
{ … }
static inline u64 snmp_fold_field64(void __percpu *mib, int offt, size_t syncp_off)
{ … }
#endif
#define snmp_get_cpu_field64_batch(buff64, stats_list, mib_statistic, offset) …
#define snmp_get_cpu_field_batch(buff, stats_list, mib_statistic) …
static inline void inet_get_local_port_range(const struct net *net, int *low, int *high)
{ … }
bool inet_sk_get_local_port_range(const struct sock *sk, int *low, int *high);
#ifdef CONFIG_SYSCTL
static inline bool inet_is_local_reserved_port(struct net *net, unsigned short port)
{ … }
static inline bool sysctl_dev_name_is_allowed(const char *name)
{ … }
static inline bool inet_port_requires_bind_service(struct net *net, unsigned short port)
{ … }
#else
static inline bool inet_is_local_reserved_port(struct net *net, unsigned short port)
{
return false;
}
static inline bool inet_port_requires_bind_service(struct net *net, unsigned short port)
{
return port < PROT_SOCK;
}
#endif
__be32 inet_current_timestamp(void);
extern int inet_peer_threshold;
extern int inet_peer_minttl;
extern int inet_peer_maxttl;
void ipfrag_init(void);
void ip_static_sysctl_init(void);
#define IP4_REPLY_MARK(net, mark) …
static inline bool ip_is_fragment(const struct iphdr *iph)
{ … }
#ifdef CONFIG_INET
#include <net/dst.h>
static inline
int ip_decrease_ttl(struct iphdr *iph)
{ … }
static inline int ip_mtu_locked(const struct dst_entry *dst)
{ … }
static inline
int ip_dont_fragment(const struct sock *sk, const struct dst_entry *dst)
{ … }
static inline bool ip_sk_accept_pmtu(const struct sock *sk)
{ … }
static inline bool ip_sk_use_pmtu(const struct sock *sk)
{ … }
static inline bool ip_sk_ignore_df(const struct sock *sk)
{ … }
static inline unsigned int ip_dst_mtu_maybe_forward(const struct dst_entry *dst,
bool forwarding)
{ … }
static inline unsigned int ip_skb_dst_mtu(struct sock *sk,
const struct sk_buff *skb)
{ … }
struct dst_metrics *ip_fib_metrics_init(struct nlattr *fc_mx, int fc_mx_len,
struct netlink_ext_ack *extack);
static inline void ip_fib_metrics_put(struct dst_metrics *fib_metrics)
{ … }
static inline
void ip_dst_init_metrics(struct dst_entry *dst, struct dst_metrics *fib_metrics)
{ … }
static inline
void ip_dst_metrics_put(struct dst_entry *dst)
{ … }
void __ip_select_ident(struct net *net, struct iphdr *iph, int segs);
static inline void ip_select_ident_segs(struct net *net, struct sk_buff *skb,
struct sock *sk, int segs)
{ … }
static inline void ip_select_ident(struct net *net, struct sk_buff *skb,
struct sock *sk)
{ … }
static inline __wsum inet_compute_pseudo(struct sk_buff *skb, int proto)
{ … }
static inline void iph_to_flow_copy_v4addrs(struct flow_keys *flow,
const struct iphdr *iph)
{ … }
static inline void ip_eth_mc_map(__be32 naddr, char *buf)
{ … }
static inline void ip_ib_mc_map(__be32 naddr, const unsigned char *broadcast, char *buf)
{ … }
static inline void ip_ipgre_mc_map(__be32 naddr, const unsigned char *broadcast, char *buf)
{ … }
#if IS_ENABLED(CONFIG_IPV6)
#include <linux/ipv6.h>
#endif
static __inline__ void inet_reset_saddr(struct sock *sk)
{ … }
#endif
static inline unsigned int ipv4_addr_hash(__be32 ip)
{ … }
static inline u32 ipv4_portaddr_hash(const struct net *net,
__be32 saddr,
unsigned int port)
{ … }
bool ip_call_ra_chain(struct sk_buff *skb);
enum ip_defrag_users { … };
static inline bool ip_defrag_user_in_between(u32 user,
enum ip_defrag_users lower_bond,
enum ip_defrag_users upper_bond)
{ … }
int ip_defrag(struct net *net, struct sk_buff *skb, u32 user);
#ifdef CONFIG_INET
struct sk_buff *ip_check_defrag(struct net *net, struct sk_buff *skb, u32 user);
#else
static inline struct sk_buff *ip_check_defrag(struct net *net, struct sk_buff *skb, u32 user)
{
return skb;
}
#endif
int ip_forward(struct sk_buff *skb);
void ip_options_build(struct sk_buff *skb, struct ip_options *opt,
__be32 daddr, struct rtable *rt);
int __ip_options_echo(struct net *net, struct ip_options *dopt,
struct sk_buff *skb, const struct ip_options *sopt);
static inline int ip_options_echo(struct net *net, struct ip_options *dopt,
struct sk_buff *skb)
{ … }
void ip_options_fragment(struct sk_buff *skb);
int __ip_options_compile(struct net *net, struct ip_options *opt,
struct sk_buff *skb, __be32 *info);
int ip_options_compile(struct net *net, struct ip_options *opt,
struct sk_buff *skb);
int ip_options_get(struct net *net, struct ip_options_rcu **optp,
sockptr_t data, int optlen);
void ip_options_undo(struct ip_options *opt);
void ip_forward_options(struct sk_buff *skb);
int ip_options_rcv_srr(struct sk_buff *skb, struct net_device *dev);
void ipv4_pktinfo_prepare(const struct sock *sk, struct sk_buff *skb, bool drop_dst);
void ip_cmsg_recv_offset(struct msghdr *msg, struct sock *sk,
struct sk_buff *skb, int tlen, int offset);
int ip_cmsg_send(struct sock *sk, struct msghdr *msg,
struct ipcm_cookie *ipc, bool allow_ipv6);
DECLARE_STATIC_KEY_FALSE(ip4_min_ttl);
int do_ip_setsockopt(struct sock *sk, int level, int optname, sockptr_t optval,
unsigned int optlen);
int ip_setsockopt(struct sock *sk, int level, int optname, sockptr_t optval,
unsigned int optlen);
int do_ip_getsockopt(struct sock *sk, int level, int optname,
sockptr_t optval, sockptr_t optlen);
int ip_getsockopt(struct sock *sk, int level, int optname, char __user *optval,
int __user *optlen);
int ip_ra_control(struct sock *sk, unsigned char on,
void (*destructor)(struct sock *));
int ip_recv_error(struct sock *sk, struct msghdr *msg, int len, int *addr_len);
void ip_icmp_error(struct sock *sk, struct sk_buff *skb, int err, __be16 port,
u32 info, u8 *payload);
void ip_local_error(struct sock *sk, int err, __be32 daddr, __be16 dport,
u32 info);
static inline void ip_cmsg_recv(struct msghdr *msg, struct sk_buff *skb)
{ … }
bool icmp_global_allow(void);
extern int sysctl_icmp_msgs_per_sec;
extern int sysctl_icmp_msgs_burst;
#ifdef CONFIG_PROC_FS
int ip_misc_proc_init(void);
#endif
int rtm_getroute_parse_ip_proto(struct nlattr *attr, u8 *ip_proto, u8 family,
struct netlink_ext_ack *extack);
static inline bool inetdev_valid_mtu(unsigned int mtu)
{ … }
void ip_sock_set_freebind(struct sock *sk);
int ip_sock_set_mtu_discover(struct sock *sk, int val);
void ip_sock_set_pktinfo(struct sock *sk);
void ip_sock_set_recverr(struct sock *sk);
void ip_sock_set_tos(struct sock *sk, int val);
void __ip_sock_set_tos(struct sock *sk, int val);
#endif