diff options
author | Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp> | 2018-07-06 11:49:00 +0900 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2018-07-07 15:25:35 -0700 |
commit | d8d7218ad842e18fc6976b87c08ed749e8d56313 (patch) | |
tree | 57cdc7f8d2c55996b0ca1b6e74a8de8fa997b29f /include | |
parent | 4fb126cbcbd6870851f0b3ba503e8ec0e66b9dd5 (diff) | |
download | linux-d8d7218ad842e18fc6976b87c08ed749e8d56313.tar.bz2 |
xdp: XDP_REDIRECT should check IFF_UP and MTU
Otherwise we end up with attempting to send packets from down devices
or to send oversized packets, which may cause unexpected driver/device
behaviour. Generic XDP has already done this check, so reuse the logic
in native XDP.
Fixes: 814abfabef3c ("xdp: add bpf_redirect helper function")
Signed-off-by: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/filter.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/include/linux/filter.h b/include/linux/filter.h index 300baad62c88..c73dd7396886 100644 --- a/include/linux/filter.h +++ b/include/linux/filter.h @@ -765,8 +765,8 @@ static inline bool bpf_dump_raw_ok(void) struct bpf_prog *bpf_patch_insn_single(struct bpf_prog *prog, u32 off, const struct bpf_insn *patch, u32 len); -static inline int __xdp_generic_ok_fwd_dev(struct sk_buff *skb, - struct net_device *fwd) +static inline int xdp_ok_fwd_dev(const struct net_device *fwd, + unsigned int pktlen) { unsigned int len; @@ -774,7 +774,7 @@ static inline int __xdp_generic_ok_fwd_dev(struct sk_buff *skb, return -ENETDOWN; len = fwd->mtu + fwd->hard_header_len + VLAN_HLEN; - if (skb->len > len) + if (pktlen > len) return -EMSGSIZE; return 0; |