Skip to content

Commit ebf4e80

Browse files
Ilya Lesokhindavem330
authored andcommitted
net: Add Software fallback infrastructure for socket dependent offloads
With socket dependent offloads we rely on the netdev to transform the transmitted packets before sending them to the wire. When a packet from an offloaded socket is rerouted to a different device we need to detect it and do the transformation in software. Signed-off-by: Ilya Lesokhin <[email protected]> Signed-off-by: Boris Pismenny <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 08303c1 commit ebf4e80

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

include/net/sock.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,11 @@ struct sock {
481481
void (*sk_error_report)(struct sock *sk);
482482
int (*sk_backlog_rcv)(struct sock *sk,
483483
struct sk_buff *skb);
484+
#ifdef CONFIG_SOCK_VALIDATE_XMIT
485+
struct sk_buff* (*sk_validate_xmit_skb)(struct sock *sk,
486+
struct net_device *dev,
487+
struct sk_buff *skb);
488+
#endif
484489
void (*sk_destruct)(struct sock *sk);
485490
struct sock_reuseport __rcu *sk_reuseport_cb;
486491
struct rcu_head sk_rcu;
@@ -2332,6 +2337,22 @@ static inline bool sk_fullsock(const struct sock *sk)
23322337
return (1 << sk->sk_state) & ~(TCPF_TIME_WAIT | TCPF_NEW_SYN_RECV);
23332338
}
23342339

2340+
/* Checks if this SKB belongs to an HW offloaded socket
2341+
* and whether any SW fallbacks are required based on dev.
2342+
*/
2343+
static inline struct sk_buff *sk_validate_xmit_skb(struct sk_buff *skb,
2344+
struct net_device *dev)
2345+
{
2346+
#ifdef CONFIG_SOCK_VALIDATE_XMIT
2347+
struct sock *sk = skb->sk;
2348+
2349+
if (sk && sk_fullsock(sk) && sk->sk_validate_xmit_skb)
2350+
skb = sk->sk_validate_xmit_skb(sk, dev, skb);
2351+
#endif
2352+
2353+
return skb;
2354+
}
2355+
23352356
/* This helper checks if a socket is a LISTEN or NEW_SYN_RECV
23362357
* SYNACK messages can be attached to either ones (depending on SYNCOOKIE)
23372358
*/

net/Kconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,9 @@ config GRO_CELLS
407407
bool
408408
default n
409409

410+
config SOCK_VALIDATE_XMIT
411+
bool
412+
410413
config NET_DEVLINK
411414
tristate "Network physical/parent device Netlink interface"
412415
help

net/core/dev.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3112,6 +3112,10 @@ static struct sk_buff *validate_xmit_skb(struct sk_buff *skb, struct net_device
31123112
if (unlikely(!skb))
31133113
goto out_null;
31143114

3115+
skb = sk_validate_xmit_skb(skb, dev);
3116+
if (unlikely(!skb))
3117+
goto out_null;
3118+
31153119
if (netif_needs_gso(skb, features)) {
31163120
struct sk_buff *segs;
31173121

0 commit comments

Comments
 (0)