Commit 4d463c4d authored by Daniel Borkmann's avatar Daniel Borkmann Committed by David S. Miller

xdp: use common helper for netlink extended ack reporting

Small follow-up to d74a32ac ("xdp: use netlink extended ACK reporting")
in order to let drivers all use the same NL_SET_ERR_MSG_MOD() helper macro
for reporting. This also ensures that we consistently add the driver's
prefix for dumping the report in user space to indicate that the error
message is driver specific and not coming from core code. Furthermore,
NL_SET_ERR_MSG_MOD() now reuses NL_SET_ERR_MSG() and thus makes all macros
check the pointer as suggested.

References: https://www.spinics.net/lists/netdev/msg433267.htmlSigned-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Acked-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: default avatarJohannes Berg <johannes@sipsolutions.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 6d717134
...@@ -2532,11 +2532,11 @@ nfp_net_check_config(struct nfp_net *nn, struct nfp_net_dp *dp, ...@@ -2532,11 +2532,11 @@ nfp_net_check_config(struct nfp_net *nn, struct nfp_net_dp *dp,
if (!dp->xdp_prog) if (!dp->xdp_prog)
return 0; return 0;
if (dp->fl_bufsz > PAGE_SIZE) { if (dp->fl_bufsz > PAGE_SIZE) {
NL_MOD_TRY_SET_ERR_MSG(extack, "MTU too large w/ XDP enabled"); NL_SET_ERR_MSG_MOD(extack, "MTU too large w/ XDP enabled");
return -EINVAL; return -EINVAL;
} }
if (dp->num_tx_rings > nn->max_tx_rings) { if (dp->num_tx_rings > nn->max_tx_rings) {
NL_MOD_TRY_SET_ERR_MSG(extack, "Insufficient number of TX rings w/ XDP enabled"); NL_SET_ERR_MSG_MOD(extack, "Insufficient number of TX rings w/ XDP enabled");
return -EINVAL; return -EINVAL;
} }
......
...@@ -1891,17 +1891,17 @@ static int virtnet_xdp_set(struct net_device *dev, struct bpf_prog *prog, ...@@ -1891,17 +1891,17 @@ static int virtnet_xdp_set(struct net_device *dev, struct bpf_prog *prog,
virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_TSO6) || virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_TSO6) ||
virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_ECN) || virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_ECN) ||
virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_UFO)) { virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_UFO)) {
NL_SET_ERR_MSG(extack, "can't set XDP while host is implementing LRO, disable LRO first"); NL_SET_ERR_MSG_MOD(extack, "Can't set XDP while host is implementing LRO, disable LRO first");
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
if (vi->mergeable_rx_bufs && !vi->any_header_sg) { if (vi->mergeable_rx_bufs && !vi->any_header_sg) {
NL_SET_ERR_MSG(extack, "XDP expects header/data in single page, any_header_sg required"); NL_SET_ERR_MSG_MOD(extack, "XDP expects header/data in single page, any_header_sg required");
return -EINVAL; return -EINVAL;
} }
if (dev->mtu > max_sz) { if (dev->mtu > max_sz) {
NL_SET_ERR_MSG(extack, "MTU too large to enable XDP"); NL_SET_ERR_MSG_MOD(extack, "MTU too large to enable XDP");
netdev_warn(dev, "XDP requires MTU less than %lu\n", max_sz); netdev_warn(dev, "XDP requires MTU less than %lu\n", max_sz);
return -EINVAL; return -EINVAL;
} }
...@@ -1912,7 +1912,7 @@ static int virtnet_xdp_set(struct net_device *dev, struct bpf_prog *prog, ...@@ -1912,7 +1912,7 @@ static int virtnet_xdp_set(struct net_device *dev, struct bpf_prog *prog,
/* XDP requires extra queues for XDP_TX */ /* XDP requires extra queues for XDP_TX */
if (curr_qp + xdp_qp > vi->max_queue_pairs) { if (curr_qp + xdp_qp > vi->max_queue_pairs) {
NL_SET_ERR_MSG(extack, "Too few free TX rings available"); NL_SET_ERR_MSG_MOD(extack, "Too few free TX rings available");
netdev_warn(dev, "request %i queues but max is %i\n", netdev_warn(dev, "request %i queues but max is %i\n",
curr_qp + xdp_qp, vi->max_queue_pairs); curr_qp + xdp_qp, vi->max_queue_pairs);
return -ENOMEM; return -ENOMEM;
......
...@@ -87,18 +87,15 @@ struct netlink_ext_ack { ...@@ -87,18 +87,15 @@ struct netlink_ext_ack {
* to the lack of an output buffer.) * to the lack of an output buffer.)
*/ */
#define NL_SET_ERR_MSG(extack, msg) do { \ #define NL_SET_ERR_MSG(extack, msg) do { \
static const char _msg[] = (msg); \ static const char __msg[] = (msg); \
struct netlink_ext_ack *__extack = (extack); \
\ \
(extack)->_msg = _msg; \ if (__extack) \
__extack->_msg = __msg; \
} while (0) } while (0)
#define NL_MOD_TRY_SET_ERR_MSG(extack, msg) do { \ #define NL_SET_ERR_MSG_MOD(extack, msg) \
static const char _msg[] = KBUILD_MODNAME ": " msg; \ NL_SET_ERR_MSG((extack), KBUILD_MODNAME ": " msg)
struct netlink_ext_ack *_extack = (extack); \
\
if (_extack) \
_extack->_msg = _msg; \
} while (0)
extern void netlink_kernel_release(struct sock *sk); extern void netlink_kernel_release(struct sock *sk);
extern int __netlink_change_ngroups(struct sock *sk, unsigned int groups); extern int __netlink_change_ngroups(struct sock *sk, unsigned int groups);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment