mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-19 00:54:41 +08:00
Merge branch 'xdp-cleanups'
Brenden Blanco says: ==================== misc cleanups for xdp This addresses several of the non-blocking comments left over from the xdp patch set. See individual patches for details. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
commit
1c137ef486
@ -535,9 +535,11 @@ void mlx4_en_destroy_rx_ring(struct mlx4_en_priv *priv,
|
|||||||
{
|
{
|
||||||
struct mlx4_en_dev *mdev = priv->mdev;
|
struct mlx4_en_dev *mdev = priv->mdev;
|
||||||
struct mlx4_en_rx_ring *ring = *pring;
|
struct mlx4_en_rx_ring *ring = *pring;
|
||||||
|
struct bpf_prog *old_prog;
|
||||||
|
|
||||||
if (ring->xdp_prog)
|
old_prog = READ_ONCE(ring->xdp_prog);
|
||||||
bpf_prog_put(ring->xdp_prog);
|
if (old_prog)
|
||||||
|
bpf_prog_put(old_prog);
|
||||||
mlx4_free_hwq_res(mdev->dev, &ring->wqres, size * stride + TXBB_SIZE);
|
mlx4_free_hwq_res(mdev->dev, &ring->wqres, size * stride + TXBB_SIZE);
|
||||||
vfree(ring->rx_info);
|
vfree(ring->rx_info);
|
||||||
ring->rx_info = NULL;
|
ring->rx_info = NULL;
|
||||||
|
@ -2109,6 +2109,10 @@ static int do_setlink(const struct sk_buff *skb,
|
|||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto errout;
|
goto errout;
|
||||||
|
|
||||||
|
if (xdp[IFLA_XDP_ATTACHED]) {
|
||||||
|
err = -EINVAL;
|
||||||
|
goto errout;
|
||||||
|
}
|
||||||
if (xdp[IFLA_XDP_FD]) {
|
if (xdp[IFLA_XDP_FD]) {
|
||||||
err = dev_change_xdp_fd(dev,
|
err = dev_change_xdp_fd(dev,
|
||||||
nla_get_s32(xdp[IFLA_XDP_FD]));
|
nla_get_s32(xdp[IFLA_XDP_FD]));
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
#include <linux/ipv6.h>
|
#include <linux/ipv6.h>
|
||||||
#include "bpf_helpers.h"
|
#include "bpf_helpers.h"
|
||||||
|
|
||||||
struct bpf_map_def SEC("maps") dropcnt = {
|
struct bpf_map_def SEC("maps") rxcnt = {
|
||||||
.type = BPF_MAP_TYPE_PERCPU_ARRAY,
|
.type = BPF_MAP_TYPE_PERCPU_ARRAY,
|
||||||
.key_size = sizeof(u32),
|
.key_size = sizeof(u32),
|
||||||
.value_size = sizeof(long),
|
.value_size = sizeof(long),
|
||||||
@ -49,7 +49,7 @@ int xdp_prog1(struct xdp_md *ctx)
|
|||||||
long *value;
|
long *value;
|
||||||
u16 h_proto;
|
u16 h_proto;
|
||||||
u64 nh_off;
|
u64 nh_off;
|
||||||
u32 index;
|
u32 ipproto;
|
||||||
|
|
||||||
nh_off = sizeof(*eth);
|
nh_off = sizeof(*eth);
|
||||||
if (data + nh_off > data_end)
|
if (data + nh_off > data_end)
|
||||||
@ -77,13 +77,13 @@ int xdp_prog1(struct xdp_md *ctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (h_proto == htons(ETH_P_IP))
|
if (h_proto == htons(ETH_P_IP))
|
||||||
index = parse_ipv4(data, nh_off, data_end);
|
ipproto = parse_ipv4(data, nh_off, data_end);
|
||||||
else if (h_proto == htons(ETH_P_IPV6))
|
else if (h_proto == htons(ETH_P_IPV6))
|
||||||
index = parse_ipv6(data, nh_off, data_end);
|
ipproto = parse_ipv6(data, nh_off, data_end);
|
||||||
else
|
else
|
||||||
index = 0;
|
ipproto = 0;
|
||||||
|
|
||||||
value = bpf_map_lookup_elem(&dropcnt, &index);
|
value = bpf_map_lookup_elem(&rxcnt, &ipproto);
|
||||||
if (value)
|
if (value)
|
||||||
*value += 1;
|
*value += 1;
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
#include <linux/ipv6.h>
|
#include <linux/ipv6.h>
|
||||||
#include "bpf_helpers.h"
|
#include "bpf_helpers.h"
|
||||||
|
|
||||||
struct bpf_map_def SEC("maps") dropcnt = {
|
struct bpf_map_def SEC("maps") rxcnt = {
|
||||||
.type = BPF_MAP_TYPE_PERCPU_ARRAY,
|
.type = BPF_MAP_TYPE_PERCPU_ARRAY,
|
||||||
.key_size = sizeof(u32),
|
.key_size = sizeof(u32),
|
||||||
.value_size = sizeof(long),
|
.value_size = sizeof(long),
|
||||||
@ -65,7 +65,7 @@ int xdp_prog1(struct xdp_md *ctx)
|
|||||||
long *value;
|
long *value;
|
||||||
u16 h_proto;
|
u16 h_proto;
|
||||||
u64 nh_off;
|
u64 nh_off;
|
||||||
u32 index;
|
u32 ipproto;
|
||||||
|
|
||||||
nh_off = sizeof(*eth);
|
nh_off = sizeof(*eth);
|
||||||
if (data + nh_off > data_end)
|
if (data + nh_off > data_end)
|
||||||
@ -93,17 +93,17 @@ int xdp_prog1(struct xdp_md *ctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (h_proto == htons(ETH_P_IP))
|
if (h_proto == htons(ETH_P_IP))
|
||||||
index = parse_ipv4(data, nh_off, data_end);
|
ipproto = parse_ipv4(data, nh_off, data_end);
|
||||||
else if (h_proto == htons(ETH_P_IPV6))
|
else if (h_proto == htons(ETH_P_IPV6))
|
||||||
index = parse_ipv6(data, nh_off, data_end);
|
ipproto = parse_ipv6(data, nh_off, data_end);
|
||||||
else
|
else
|
||||||
index = 0;
|
ipproto = 0;
|
||||||
|
|
||||||
value = bpf_map_lookup_elem(&dropcnt, &index);
|
value = bpf_map_lookup_elem(&rxcnt, &ipproto);
|
||||||
if (value)
|
if (value)
|
||||||
*value += 1;
|
*value += 1;
|
||||||
|
|
||||||
if (index == 17) {
|
if (ipproto == IPPROTO_UDP) {
|
||||||
swap_src_dst_mac(data);
|
swap_src_dst_mac(data);
|
||||||
rc = XDP_TX;
|
rc = XDP_TX;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user