summaryrefslogtreecommitdiffstats
path: root/net/xdp
diff options
context:
space:
mode:
authorMaxim Mikityanskiy <maximmi@mellanox.com>2019-06-26 10:35:25 -0400
committerDaniel Borkmann <daniel@iogearbox.net>2019-06-27 16:53:26 -0400
commit2640d3c8123223e0a205b2a25a446df6f072b3ea (patch)
tree363a9ed3c58920994273d03e3c8aa976382f181e /net/xdp
parentd57d76428ae9abca51fb89f9326da9d4b1cf8270 (diff)
xsk: Add getsockopt XDP_OPTIONS
Make it possible for the application to determine whether the AF_XDP socket is running in zero-copy mode. To achieve this, add a new getsockopt option XDP_OPTIONS that returns flags. The only flag supported for now is the zero-copy mode indicator. Signed-off-by: Maxim Mikityanskiy <maximmi@mellanox.com> Signed-off-by: Tariq Toukan <tariqt@mellanox.com> Acked-by: Saeed Mahameed <saeedm@mellanox.com> Acked-by: Björn Töpel <bjorn.topel@intel.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'net/xdp')
-rw-r--r--net/xdp/xsk.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
index b68a380f50b3..35ca531ac74e 100644
--- a/net/xdp/xsk.c
+++ b/net/xdp/xsk.c
@@ -650,6 +650,26 @@ static int xsk_getsockopt(struct socket *sock, int level, int optname,
650 650
651 return 0; 651 return 0;
652 } 652 }
653 case XDP_OPTIONS:
654 {
655 struct xdp_options opts = {};
656
657 if (len < sizeof(opts))
658 return -EINVAL;
659
660 mutex_lock(&xs->mutex);
661 if (xs->zc)
662 opts.flags |= XDP_OPTIONS_ZEROCOPY;
663 mutex_unlock(&xs->mutex);
664
665 len = sizeof(opts);
666 if (copy_to_user(optval, &opts, len))
667 return -EFAULT;
668 if (put_user(len, optlen))
669 return -EFAULT;
670
671 return 0;
672 }
653 default: 673 default:
654 break; 674 break;
655 } 675 }