Unverified Commit 5088b701 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!12048 Add generic xdp xsk multi-buffer recv for ipvlan

Merge Pull Request from: @ci-robot 
 
PR sync from: Yue Haibing <yuehaibing@huawei.com>
https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/LIPZG4TUHGU2R6AU5DEWFMHL5XFZKLQ3/ 
Yue Haibing (1):
  xsk: Add generic xdp multi-buffer recv support

bitcoffee (1):


-- 
2.34.1
 
https://gitee.com/openeuler/kernel/issues/IAOZOH 
 
Link:https://gitee.com/openeuler/kernel/pulls/12048

 

Reviewed-by: default avatarYang Yingliang <yangyingliang@huawei.com>
Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
parents 4a55bddc 930f681f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1154,6 +1154,7 @@ CONFIG_SMC=m
CONFIG_SMC_DIAG=m
CONFIG_XDP_SOCKETS=y
# CONFIG_XDP_SOCKETS_DIAG is not set
# CONFIG_XSK_MULTI_BUF is not set
CONFIG_INET=y
CONFIG_IP_MULTICAST=y
CONFIG_IP_ADVANCED_ROUTER=y
+1 −0
Original line number Diff line number Diff line
@@ -77,6 +77,7 @@ struct ipvl_dev {
	unsigned long           local_timeout;
	struct timer_list       local_free_timer;
	struct sk_buff_head     local_xmit_queue;
	struct bpf_prog __rcu   *xdp_prog;
};

struct ipvl_addr {
+16 −0
Original line number Diff line number Diff line
@@ -314,11 +314,27 @@ static int ipvlan_rcv_frame(struct ipvl_addr *addr, struct sk_buff **pskb,
{
	struct ipvl_dev *ipvlan = addr->master;
	struct net_device *dev = ipvlan->dev;
	struct bpf_prog *xdp_prog = rtnl_dereference(ipvlan->xdp_prog);
	unsigned int len;
	rx_handler_result_t ret = RX_HANDLER_CONSUMED;
	bool success = false;
	struct sk_buff *skb = *pskb;
	struct net_device *old_dev = skb->dev;
	int xdp_ret;

	if (!xdp_prog)
		goto go_network_stack;
	skb->dev = dev;
#ifdef CONFIG_XSK_MULTI_BUF
	xdp_ret = do_xdp_generic_multi(xdp_prog, &skb);
#else
	xdp_ret = do_xdp_generic(xdp_prog, skb);
#endif
	if (xdp_ret != XDP_PASS)
		return ret;
	skb->dev = old_dev;

go_network_stack:
	len = skb->len + ETH_HLEN;
	/* Only packets exchanged between two local slaves need to have
	 * device-up check as well as skb-share check.
+22 −0
Original line number Diff line number Diff line
@@ -424,6 +424,27 @@ static int ipvlan_get_iflink(const struct net_device *dev)
	return ipvlan->phy_dev->ifindex;
}

static int ipvlan_xdp_set(struct net_device *dev, struct bpf_prog *prog,
			  struct netlink_ext_ack *extack)
{
	struct ipvl_dev *priv = netdev_priv(dev);
	struct bpf_prog *old_prog;

	old_prog = rtnl_dereference(priv->xdp_prog);
	rcu_assign_pointer(priv->xdp_prog, prog);
	return 0;
}

static int ipvlan_xdp(struct net_device *dev, struct netdev_bpf *xdp)
{
	switch (xdp->command) {
	case XDP_SETUP_PROG:
		return ipvlan_xdp_set(dev, xdp->prog, xdp->extack);
	default:
		return -EINVAL;
	}
}

static const struct net_device_ops ipvlan_netdev_ops = {
	.ndo_init		= ipvlan_init,
	.ndo_uninit		= ipvlan_uninit,
@@ -437,6 +458,7 @@ static const struct net_device_ops ipvlan_netdev_ops = {
	.ndo_vlan_rx_add_vid	= ipvlan_vlan_rx_add_vid,
	.ndo_vlan_rx_kill_vid	= ipvlan_vlan_rx_kill_vid,
	.ndo_get_iflink		= ipvlan_get_iflink,
	.ndo_bpf		= ipvlan_xdp,
};

static int ipvlan_hard_header(struct sk_buff *skb, struct net_device *dev,
+7 −0
Original line number Diff line number Diff line
@@ -1620,6 +1620,8 @@ struct net_device_ops {
 * @IFF_FAILOVER_SLAVE: device is lower dev of a failover master device
 * @IFF_L3MDEV_RX_HANDLER: only invoke the rx handler of L3 master device
 * @IFF_LIVE_RENAME_OK: rename is allowed while device is up and running
 * @IFF_TX_SKB_NO_LINEAR: device/driver is capable of xmitting frames with
 *	skb_headlen(skb) == 0 (data starts from frag0)
 */
enum netdev_priv_flags {
	IFF_802_1Q_VLAN			= 1<<0,
@@ -1653,6 +1655,7 @@ enum netdev_priv_flags {
	IFF_FAILOVER_SLAVE		= 1<<28,
	IFF_L3MDEV_RX_HANDLER		= 1<<29,
	IFF_LIVE_RENAME_OK		= 1<<30,
	IFF_TX_SKB_NO_LINEAR		= 1<<31,
};

#define IFF_802_1Q_VLAN			IFF_802_1Q_VLAN
@@ -1685,6 +1688,7 @@ enum netdev_priv_flags {
#define IFF_FAILOVER_SLAVE		IFF_FAILOVER_SLAVE
#define IFF_L3MDEV_RX_HANDLER		IFF_L3MDEV_RX_HANDLER
#define IFF_LIVE_RENAME_OK		IFF_LIVE_RENAME_OK
#define IFF_TX_SKB_NO_LINEAR		IFF_TX_SKB_NO_LINEAR

/* Specifies the type of the struct net_device::ml_priv pointer */
enum netdev_ml_priv_type {
@@ -3953,6 +3957,9 @@ static inline void dev_consume_skb_any(struct sk_buff *skb)

void generic_xdp_tx(struct sk_buff *skb, struct bpf_prog *xdp_prog);
int do_xdp_generic(struct bpf_prog *xdp_prog, struct sk_buff *skb);
#ifdef CONFIG_XSK_MULTI_BUF
int do_xdp_generic_multi(struct bpf_prog *xdp_prog, struct sk_buff **pskb);
#endif
int netif_rx(struct sk_buff *skb);
int netif_rx_ni(struct sk_buff *skb);
int netif_rx_any_context(struct sk_buff *skb);
Loading