hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/net/packet/internal.h
....@@ -39,7 +39,7 @@
3939 char *nxt_offset;
4040 struct sk_buff *skb;
4141
42
- atomic_t blk_fill_in_prog;
42
+ rwlock_t blk_fill_in_prog_lock;
4343
4444 /* Default is set to 8ms */
4545 #define DEFAULT_PRB_RETIRE_TOV (8)
....@@ -77,11 +77,12 @@
7777 };
7878
7979 extern struct mutex fanout_mutex;
80
-#define PACKET_FANOUT_MAX 256
80
+#define PACKET_FANOUT_MAX (1 << 16)
8181
8282 struct packet_fanout {
8383 possible_net_t net;
8484 unsigned int num_members;
85
+ u32 max_num_members;
8586 u16 id;
8687 u8 type;
8788 u8 flags;
....@@ -90,10 +91,10 @@
9091 struct bpf_prog __rcu *bpf_prog;
9192 };
9293 struct list_head list;
93
- struct sock *arr[PACKET_FANOUT_MAX];
9494 spinlock_t lock;
9595 refcount_t sk_ref;
9696 struct packet_type prot_hook ____cacheline_aligned_in_smp;
97
+ struct sock __rcu *arr[];
9798 };
9899
99100 struct packet_rollover {
....@@ -115,10 +116,9 @@
115116 int copy_thresh;
116117 spinlock_t bind_lock;
117118 struct mutex pg_vec_lock;
119
+ unsigned long flags;
118120 unsigned int running; /* bind_lock must be held */
119
- unsigned int auxdata:1, /* writer must hold sock lock */
120
- origdev:1,
121
- has_vnet_hdr:1,
121
+ unsigned int has_vnet_hdr:1, /* writer must hold sock lock */
122122 tp_loss:1,
123123 tp_tx_has_off:1;
124124 int pressure;
....@@ -135,6 +135,7 @@
135135 struct net_device __rcu *cached_dev;
136136 int (*xmit)(struct sk_buff *skb);
137137 struct packet_type prot_hook ____cacheline_aligned_in_smp;
138
+ atomic_t tp_drops ____cacheline_aligned_in_smp;
138139 };
139140
140141 static struct packet_sock *pkt_sk(struct sock *sk)
....@@ -142,4 +143,25 @@
142143 return (struct packet_sock *)sk;
143144 }
144145
146
+enum packet_sock_flags {
147
+ PACKET_SOCK_ORIGDEV,
148
+ PACKET_SOCK_AUXDATA,
149
+};
150
+
151
+static inline void packet_sock_flag_set(struct packet_sock *po,
152
+ enum packet_sock_flags flag,
153
+ bool val)
154
+{
155
+ if (val)
156
+ set_bit(flag, &po->flags);
157
+ else
158
+ clear_bit(flag, &po->flags);
159
+}
160
+
161
+static inline bool packet_sock_flag(const struct packet_sock *po,
162
+ enum packet_sock_flags flag)
163
+{
164
+ return test_bit(flag, &po->flags);
165
+}
166
+
145167 #endif