diff options
| author | Anton Ivanov <anton.ivanov@cambridgegreys.com> | 2018-03-05 08:29:05 -0500 |
|---|---|---|
| committer | Richard Weinberger <richard@nod.at> | 2018-03-29 16:18:02 -0400 |
| commit | e40238dedb484c8a19f8257e4ef5d77d038f9ad8 (patch) | |
| tree | 8bef9aea1db074cf8406f0c6da1d627da35e9449 | |
| parent | ce471fdbc6173eed5af52df3dca179a509f483d9 (diff) | |
Fix vector raw inintialization logic
Vector RAW in UML needs to BPF filter its own MAC only
if QDISC_BYPASS has failed. If QDISC_BYPASS is successful, the
frames originated locally are not visible to readers on the
raw socket.
Signed-off-by: Anton Ivanov <anton.ivanov@cambridgegreys.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
| -rw-r--r-- | arch/um/drivers/vector_kern.c | 7 | ||||
| -rw-r--r-- | arch/um/drivers/vector_kern.h | 1 | ||||
| -rw-r--r-- | arch/um/drivers/vector_user.c | 22 | ||||
| -rw-r--r-- | arch/um/drivers/vector_user.h | 1 |
4 files changed, 21 insertions, 10 deletions
diff --git a/arch/um/drivers/vector_kern.c b/arch/um/drivers/vector_kern.c index 3c764830b93e..02168fe25105 100644 --- a/arch/um/drivers/vector_kern.c +++ b/arch/um/drivers/vector_kern.c | |||
| @@ -188,7 +188,7 @@ static int get_transport_options(struct arglist *def) | |||
| 188 | if (strncmp(transport, TRANS_TAP, TRANS_TAP_LEN) == 0) | 188 | if (strncmp(transport, TRANS_TAP, TRANS_TAP_LEN) == 0) |
| 189 | return (vec_rx | VECTOR_BPF); | 189 | return (vec_rx | VECTOR_BPF); |
| 190 | if (strncmp(transport, TRANS_RAW, TRANS_RAW_LEN) == 0) | 190 | if (strncmp(transport, TRANS_RAW, TRANS_RAW_LEN) == 0) |
| 191 | return (vec_rx | vec_tx | VECTOR_BPF); | 191 | return (vec_rx | vec_tx); |
| 192 | return (vec_rx | vec_tx); | 192 | return (vec_rx | vec_tx); |
| 193 | } | 193 | } |
| 194 | 194 | ||
| @@ -1230,6 +1230,11 @@ static int vector_net_open(struct net_device *dev) | |||
| 1230 | irq_rr = (irq_rr + 1) % VECTOR_IRQ_SPACE; | 1230 | irq_rr = (irq_rr + 1) % VECTOR_IRQ_SPACE; |
| 1231 | } | 1231 | } |
| 1232 | 1232 | ||
| 1233 | if ((vp->options & VECTOR_QDISC_BYPASS) != 0) { | ||
| 1234 | if (!uml_raw_enable_qdisc_bypass(vp->fds->rx_fd)) | ||
| 1235 | vp->options = vp->options | VECTOR_BPF; | ||
| 1236 | } | ||
| 1237 | |||
| 1233 | if ((vp->options & VECTOR_BPF) != 0) | 1238 | if ((vp->options & VECTOR_BPF) != 0) |
| 1234 | vp->bpf = uml_vector_default_bpf(vp->fds->rx_fd, dev->dev_addr); | 1239 | vp->bpf = uml_vector_default_bpf(vp->fds->rx_fd, dev->dev_addr); |
| 1235 | 1240 | ||
diff --git a/arch/um/drivers/vector_kern.h b/arch/um/drivers/vector_kern.h index 699696deb396..0b0a767b9076 100644 --- a/arch/um/drivers/vector_kern.h +++ b/arch/um/drivers/vector_kern.h | |||
| @@ -28,6 +28,7 @@ | |||
| 28 | #define VECTOR_RX 1 | 28 | #define VECTOR_RX 1 |
| 29 | #define VECTOR_TX (1 << 1) | 29 | #define VECTOR_TX (1 << 1) |
| 30 | #define VECTOR_BPF (1 << 2) | 30 | #define VECTOR_BPF (1 << 2) |
| 31 | #define VECTOR_QDISC_BYPASS (1 << 3) | ||
| 31 | 32 | ||
| 32 | #define ETH_MAX_PACKET 1500 | 33 | #define ETH_MAX_PACKET 1500 |
| 33 | #define ETH_HEADER_OTHER 32 /* just in case someone decides to go mad on QnQ */ | 34 | #define ETH_HEADER_OTHER 32 /* just in case someone decides to go mad on QnQ */ |
diff --git a/arch/um/drivers/vector_user.c b/arch/um/drivers/vector_user.c index 4291f1a5d342..4d6a78e31089 100644 --- a/arch/um/drivers/vector_user.c +++ b/arch/um/drivers/vector_user.c | |||
| @@ -41,7 +41,6 @@ | |||
| 41 | #define TRANS_RAW "raw" | 41 | #define TRANS_RAW "raw" |
| 42 | #define TRANS_RAW_LEN strlen(TRANS_RAW) | 42 | #define TRANS_RAW_LEN strlen(TRANS_RAW) |
| 43 | 43 | ||
| 44 | #define QDISC_FAIL "user_init_raw: could not disable qdisc on interface" | ||
| 45 | #define VNET_HDR_FAIL "could not enable vnet headers on fd %d" | 44 | #define VNET_HDR_FAIL "could not enable vnet headers on fd %d" |
| 46 | #define TUN_GET_F_FAIL "tapraw: TUNGETFEATURES failed: %s" | 45 | #define TUN_GET_F_FAIL "tapraw: TUNGETFEATURES failed: %s" |
| 47 | #define L2TPV3_BIND_FAIL "l2tpv3_open : could not bind socket err=%i" | 46 | #define L2TPV3_BIND_FAIL "l2tpv3_open : could not bind socket err=%i" |
| @@ -212,8 +211,6 @@ static struct vector_fds *user_init_raw_fds(struct arglist *ifspec) | |||
| 212 | int err = -ENOMEM; | 211 | int err = -ENOMEM; |
| 213 | char *iface; | 212 | char *iface; |
| 214 | struct vector_fds *result = NULL; | 213 | struct vector_fds *result = NULL; |
| 215 | int optval = 1; | ||
| 216 | |||
| 217 | 214 | ||
| 218 | iface = uml_vector_fetch_arg(ifspec, TOKEN_IFNAME); | 215 | iface = uml_vector_fetch_arg(ifspec, TOKEN_IFNAME); |
| 219 | if (iface == NULL) | 216 | if (iface == NULL) |
| @@ -256,12 +253,6 @@ static struct vector_fds *user_init_raw_fds(struct arglist *ifspec) | |||
| 256 | goto cleanup; | 253 | goto cleanup; |
| 257 | } | 254 | } |
| 258 | 255 | ||
| 259 | if (setsockopt(txfd, | ||
| 260 | SOL_PACKET, PACKET_QDISC_BYPASS, | ||
| 261 | &optval, sizeof(optval)) != 0) { | ||
| 262 | printk(UM_KERN_INFO QDISC_FAIL); | ||
| 263 | } | ||
| 264 | |||
| 265 | result = uml_kmalloc(sizeof(struct vector_fds), UM_GFP_KERNEL); | 256 | result = uml_kmalloc(sizeof(struct vector_fds), UM_GFP_KERNEL); |
| 266 | if (result != NULL) { | 257 | if (result != NULL) { |
| 267 | result->rx_fd = rxfd; | 258 | result->rx_fd = rxfd; |
| @@ -281,6 +272,19 @@ cleanup: | |||
| 281 | return NULL; | 272 | return NULL; |
| 282 | } | 273 | } |
| 283 | 274 | ||
| 275 | |||
| 276 | bool uml_raw_enable_qdisc_bypass(int fd) | ||
| 277 | { | ||
| 278 | int optval = 1; | ||
| 279 | |||
| 280 | if (setsockopt(fd, | ||
| 281 | SOL_PACKET, PACKET_QDISC_BYPASS, | ||
| 282 | &optval, sizeof(optval)) != 0) { | ||
| 283 | return false; | ||
| 284 | } | ||
| 285 | return true; | ||
| 286 | } | ||
| 287 | |||
| 284 | bool uml_raw_enable_vnet_headers(int fd) | 288 | bool uml_raw_enable_vnet_headers(int fd) |
| 285 | { | 289 | { |
| 286 | int optval = 1; | 290 | int optval = 1; |
diff --git a/arch/um/drivers/vector_user.h b/arch/um/drivers/vector_user.h index 421092c57bb7..d7cbff73b7ff 100644 --- a/arch/um/drivers/vector_user.h +++ b/arch/um/drivers/vector_user.h | |||
| @@ -92,6 +92,7 @@ extern int uml_vector_recvmmsg( | |||
| 92 | ); | 92 | ); |
| 93 | extern void *uml_vector_default_bpf(int fd, void *mac); | 93 | extern void *uml_vector_default_bpf(int fd, void *mac); |
| 94 | extern int uml_vector_attach_bpf(int fd, void *bpf, int bpf_len); | 94 | extern int uml_vector_attach_bpf(int fd, void *bpf, int bpf_len); |
| 95 | extern bool uml_raw_enable_qdisc_bypass(int fd); | ||
| 95 | extern bool uml_raw_enable_vnet_headers(int fd); | 96 | extern bool uml_raw_enable_vnet_headers(int fd); |
| 96 | extern bool uml_tap_enable_vnet_headers(int fd); | 97 | extern bool uml_tap_enable_vnet_headers(int fd); |
| 97 | 98 | ||
