2019-05-27 08:55:01 +02:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
2005-04-16 15:20:36 -07:00
|
|
|
/*
|
|
|
|
|
* INET An implementation of the TCP/IP protocol suite for the LINUX
|
|
|
|
|
* operating system. INET is implemented using the BSD Socket
|
|
|
|
|
* interface as the means of communication with the user level.
|
|
|
|
|
*
|
|
|
|
|
* Definitions for the RAW-IP module.
|
|
|
|
|
*
|
|
|
|
|
* Version: @(#)raw.h 1.0.2 05/07/93
|
|
|
|
|
*
|
|
|
|
|
* Author: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
|
|
|
|
|
*/
|
|
|
|
|
#ifndef _RAW_H
|
|
|
|
|
#define _RAW_H
|
|
|
|
|
|
2018-11-07 15:36:06 +00:00
|
|
|
#include <net/inet_sock.h>
|
2005-12-27 02:43:12 -02:00
|
|
|
#include <net/protocol.h>
|
2023-02-02 09:41:00 +00:00
|
|
|
#include <net/netns/hash.h>
|
|
|
|
|
#include <linux/hash.h>
|
2010-04-13 05:03:18 +00:00
|
|
|
#include <linux/icmp.h>
|
2005-12-27 02:43:12 -02:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
extern struct proto raw_prot;
|
|
|
|
|
|
2016-10-21 13:03:44 +03:00
|
|
|
extern struct raw_hashinfo raw_v4_hashinfo;
|
2023-03-16 15:32:01 +00:00
|
|
|
bool raw_v4_match(struct net *net, const struct sock *sk, unsigned short num,
|
2022-06-17 20:47:04 -07:00
|
|
|
__be32 raddr, __be32 laddr, int dif, int sdif);
|
2016-10-21 13:03:44 +03:00
|
|
|
|
|
|
|
|
int raw_abort(struct sock *sk, int err);
|
2007-11-19 22:35:07 -08:00
|
|
|
void raw_icmp_error(struct sk_buff *, int, u32);
|
|
|
|
|
int raw_local_deliver(struct sk_buff *, int);
|
|
|
|
|
|
2013-09-22 10:32:19 -07:00
|
|
|
int raw_rcv(struct sock *, struct sk_buff *);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2023-02-02 09:41:00 +00:00
|
|
|
#define RAW_HTABLE_LOG 8
|
|
|
|
|
#define RAW_HTABLE_SIZE (1U << RAW_HTABLE_LOG)
|
2007-11-19 22:36:45 -08:00
|
|
|
|
|
|
|
|
struct raw_hashinfo {
|
2022-06-20 03:05:09 -07:00
|
|
|
spinlock_t lock;
|
2023-02-02 09:41:00 +00:00
|
|
|
|
2023-04-03 12:49:58 -07:00
|
|
|
struct hlist_head ht[RAW_HTABLE_SIZE] ____cacheline_aligned;
|
2007-11-19 22:36:45 -08:00
|
|
|
};
|
|
|
|
|
|
2023-02-02 09:41:00 +00:00
|
|
|
static inline u32 raw_hashfunc(const struct net *net, u32 proto)
|
|
|
|
|
{
|
|
|
|
|
return hash_32(net_hash_mix(net) ^ proto, RAW_HTABLE_LOG);
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-17 20:47:05 -07:00
|
|
|
static inline void raw_hashinfo_init(struct raw_hashinfo *hashinfo)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
2022-06-20 03:05:09 -07:00
|
|
|
spin_lock_init(&hashinfo->lock);
|
2022-06-17 20:47:05 -07:00
|
|
|
for (i = 0; i < RAW_HTABLE_SIZE; i++)
|
2023-04-03 12:49:58 -07:00
|
|
|
INIT_HLIST_HEAD(&hashinfo->ht[i]);
|
2022-06-17 20:47:05 -07:00
|
|
|
}
|
|
|
|
|
|
2005-08-16 02:18:02 -03:00
|
|
|
#ifdef CONFIG_PROC_FS
|
2013-09-22 10:32:19 -07:00
|
|
|
int raw_proc_init(void);
|
|
|
|
|
void raw_proc_exit(void);
|
2007-11-19 22:38:33 -08:00
|
|
|
|
|
|
|
|
struct raw_iter_state {
|
2008-01-14 05:35:57 -08:00
|
|
|
struct seq_net_private p;
|
2007-11-19 22:38:33 -08:00
|
|
|
int bucket;
|
|
|
|
|
};
|
|
|
|
|
|
2010-09-07 05:55:38 +00:00
|
|
|
static inline struct raw_iter_state *raw_seq_private(struct seq_file *seq)
|
|
|
|
|
{
|
|
|
|
|
return seq->private;
|
|
|
|
|
}
|
2007-11-19 22:38:33 -08:00
|
|
|
void *raw_seq_start(struct seq_file *seq, loff_t *pos);
|
|
|
|
|
void *raw_seq_next(struct seq_file *seq, void *v, loff_t *pos);
|
|
|
|
|
void raw_seq_stop(struct seq_file *seq, void *v);
|
2005-08-16 02:18:02 -03:00
|
|
|
#endif
|
|
|
|
|
|
2016-02-10 11:50:35 -05:00
|
|
|
int raw_hash_sk(struct sock *sk);
|
2008-03-22 16:56:51 -07:00
|
|
|
void raw_unhash_sk(struct sock *sk);
|
2018-11-07 15:36:05 +00:00
|
|
|
void raw_init(void);
|
2007-11-19 22:37:24 -08:00
|
|
|
|
2010-04-13 05:03:18 +00:00
|
|
|
struct raw_sock {
|
|
|
|
|
/* inet_sock has to be the first member */
|
|
|
|
|
struct inet_sock inet;
|
|
|
|
|
struct icmp_filter filter;
|
2010-04-13 05:03:23 +00:00
|
|
|
u32 ipmr_table;
|
2025-09-09 12:19:42 +00:00
|
|
|
struct numa_drop_counters drop_counters;
|
2010-04-13 05:03:18 +00:00
|
|
|
};
|
|
|
|
|
|
2023-03-17 15:55:32 +00:00
|
|
|
#define raw_sk(ptr) container_of_const(ptr, struct raw_sock, inet.sk)
|
2010-04-13 05:03:18 +00:00
|
|
|
|
2018-11-07 15:36:06 +00:00
|
|
|
static inline bool raw_sk_bound_dev_eq(struct net *net, int bound_dev_if,
|
|
|
|
|
int dif, int sdif)
|
|
|
|
|
{
|
|
|
|
|
#if IS_ENABLED(CONFIG_NET_L3_MASTER_DEV)
|
2022-07-11 17:15:29 -07:00
|
|
|
return inet_bound_dev_eq(READ_ONCE(net->ipv4.sysctl_raw_l3mdev_accept),
|
2018-11-07 15:36:06 +00:00
|
|
|
bound_dev_if, dif, sdif);
|
|
|
|
|
#else
|
|
|
|
|
return inet_bound_dev_eq(true, bound_dev_if, dif, sdif);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
#endif /* _RAW_H */
|