mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 19:21:31 -04:00
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 <[email protected]> Signed-off-by: Tariq Toukan <[email protected]> Acked-by: Saeed Mahameed <[email protected]> Acked-by: Björn Töpel <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]>
This commit is contained in:
parent
d57d76428a
commit
2640d3c812
3 changed files with 36 additions and 0 deletions
|
|
@ -650,6 +650,26 @@ static int xsk_getsockopt(struct socket *sock, int level, int optname,
|
|||
|
||||
return 0;
|
||||
}
|
||||
case XDP_OPTIONS:
|
||||
{
|
||||
struct xdp_options opts = {};
|
||||
|
||||
if (len < sizeof(opts))
|
||||
return -EINVAL;
|
||||
|
||||
mutex_lock(&xs->mutex);
|
||||
if (xs->zc)
|
||||
opts.flags |= XDP_OPTIONS_ZEROCOPY;
|
||||
mutex_unlock(&xs->mutex);
|
||||
|
||||
len = sizeof(opts);
|
||||
if (copy_to_user(optval, &opts, len))
|
||||
return -EFAULT;
|
||||
if (put_user(len, optlen))
|
||||
return -EFAULT;
|
||||
|
||||
return 0;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue