diff options
author | Andrew Melnychenko <andrew@daynix.com> | 2021-05-14 14:48:30 +0300 |
---|---|---|
committer | Jason Wang <jasowang@redhat.com> | 2021-06-04 15:25:46 +0800 |
commit | 8f364e344c3e71d4cc4e683d21241f6c36d62a5e (patch) | |
tree | 5ba18bb9310ff32504c4d5bcb48e4c6e2136c698 /net | |
parent | 78258debe03c6034365884cbfb05679d6938aaac (diff) | |
download | qemu-8f364e344c3e71d4cc4e683d21241f6c36d62a5e.zip qemu-8f364e344c3e71d4cc4e683d21241f6c36d62a5e.tar.gz qemu-8f364e344c3e71d4cc4e683d21241f6c36d62a5e.tar.bz2 |
net: Added SetSteeringEBPF method for NetClientState.
For now, that method supported only by Linux TAP.
Linux TAP uses TUNSETSTEERINGEBPF ioctl.
Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/tap-bsd.c | 5 | ||||
-rw-r--r-- | net/tap-linux.c | 13 | ||||
-rw-r--r-- | net/tap-solaris.c | 5 | ||||
-rw-r--r-- | net/tap-stub.c | 5 | ||||
-rw-r--r-- | net/tap.c | 9 | ||||
-rw-r--r-- | net/tap_int.h | 1 |
6 files changed, 38 insertions, 0 deletions
diff --git a/net/tap-bsd.c b/net/tap-bsd.c index 77aaf67..4f64f31 100644 --- a/net/tap-bsd.c +++ b/net/tap-bsd.c @@ -259,3 +259,8 @@ int tap_fd_get_ifname(int fd, char *ifname) { return -1; } + +int tap_fd_set_steering_ebpf(int fd, int prog_fd) +{ + return -1; +} diff --git a/net/tap-linux.c b/net/tap-linux.c index b0635e9..9584769 100644 --- a/net/tap-linux.c +++ b/net/tap-linux.c @@ -316,3 +316,16 @@ int tap_fd_get_ifname(int fd, char *ifname) pstrcpy(ifname, sizeof(ifr.ifr_name), ifr.ifr_name); return 0; } + +int tap_fd_set_steering_ebpf(int fd, int prog_fd) +{ + if (ioctl(fd, TUNSETSTEERINGEBPF, (void *) &prog_fd) != 0) { + error_report("Issue while setting TUNSETSTEERINGEBPF:" + " %s with fd: %d, prog_fd: %d", + strerror(errno), fd, prog_fd); + + return -1; + } + + return 0; +} diff --git a/net/tap-solaris.c b/net/tap-solaris.c index 0475a58..d852242 100644 --- a/net/tap-solaris.c +++ b/net/tap-solaris.c @@ -255,3 +255,8 @@ int tap_fd_get_ifname(int fd, char *ifname) { return -1; } + +int tap_fd_set_steering_ebpf(int fd, int prog_fd) +{ + return -1; +} diff --git a/net/tap-stub.c b/net/tap-stub.c index de525a2..a0fa258 100644 --- a/net/tap-stub.c +++ b/net/tap-stub.c @@ -85,3 +85,8 @@ int tap_fd_get_ifname(int fd, char *ifname) { return -1; } + +int tap_fd_set_steering_ebpf(int fd, int prog_fd) +{ + return -1; +} @@ -347,6 +347,14 @@ static void tap_poll(NetClientState *nc, bool enable) tap_write_poll(s, enable); } +static bool tap_set_steering_ebpf(NetClientState *nc, int prog_fd) +{ + TAPState *s = DO_UPCAST(TAPState, nc, nc); + assert(nc->info->type == NET_CLIENT_DRIVER_TAP); + + return tap_fd_set_steering_ebpf(s->fd, prog_fd) == 0; +} + int tap_get_fd(NetClientState *nc) { TAPState *s = DO_UPCAST(TAPState, nc, nc); @@ -372,6 +380,7 @@ static NetClientInfo net_tap_info = { .set_vnet_hdr_len = tap_set_vnet_hdr_len, .set_vnet_le = tap_set_vnet_le, .set_vnet_be = tap_set_vnet_be, + .set_steering_ebpf = tap_set_steering_ebpf, }; static TAPState *net_tap_fd_init(NetClientState *peer, diff --git a/net/tap_int.h b/net/tap_int.h index 225a49e..547f8a5 100644 --- a/net/tap_int.h +++ b/net/tap_int.h @@ -44,5 +44,6 @@ int tap_fd_set_vnet_be(int fd, int vnet_is_be); int tap_fd_enable(int fd); int tap_fd_disable(int fd); int tap_fd_get_ifname(int fd, char *ifname); +int tap_fd_set_steering_ebpf(int fd, int prog_fd); #endif /* NET_TAP_INT_H */ |