diff options
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/pktgen.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/net/core/pktgen.c b/net/core/pktgen.c index 8bc4ddd375a9..628f7c572c6e 100644 --- a/net/core/pktgen.c +++ b/net/core/pktgen.c | |||
@@ -390,6 +390,8 @@ struct pktgen_dev { | |||
390 | __u8 ipsmode; /* IPSEC mode (config) */ | 390 | __u8 ipsmode; /* IPSEC mode (config) */ |
391 | __u8 ipsproto; /* IPSEC type (config) */ | 391 | __u8 ipsproto; /* IPSEC type (config) */ |
392 | __u32 spi; | 392 | __u32 spi; |
393 | struct dst_entry dst; | ||
394 | struct dst_ops dstops; | ||
393 | #endif | 395 | #endif |
394 | char result[512]; | 396 | char result[512]; |
395 | }; | 397 | }; |
@@ -2487,6 +2489,11 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev) | |||
2487 | 2489 | ||
2488 | 2490 | ||
2489 | #ifdef CONFIG_XFRM | 2491 | #ifdef CONFIG_XFRM |
2492 | u32 pktgen_dst_metrics[RTAX_MAX + 1] = { | ||
2493 | |||
2494 | [RTAX_HOPLIMIT] = 0x5, /* Set a static hoplimit */ | ||
2495 | }; | ||
2496 | |||
2490 | static int pktgen_output_ipsec(struct sk_buff *skb, struct pktgen_dev *pkt_dev) | 2497 | static int pktgen_output_ipsec(struct sk_buff *skb, struct pktgen_dev *pkt_dev) |
2491 | { | 2498 | { |
2492 | struct xfrm_state *x = pkt_dev->flows[pkt_dev->curfl].x; | 2499 | struct xfrm_state *x = pkt_dev->flows[pkt_dev->curfl].x; |
@@ -2497,10 +2504,18 @@ static int pktgen_output_ipsec(struct sk_buff *skb, struct pktgen_dev *pkt_dev) | |||
2497 | return 0; | 2504 | return 0; |
2498 | /* XXX: we dont support tunnel mode for now until | 2505 | /* XXX: we dont support tunnel mode for now until |
2499 | * we resolve the dst issue */ | 2506 | * we resolve the dst issue */ |
2500 | if (x->props.mode != XFRM_MODE_TRANSPORT) | 2507 | if ((x->props.mode != XFRM_MODE_TRANSPORT) && (pkt_dev->spi == 0)) |
2501 | return 0; | 2508 | return 0; |
2502 | 2509 | ||
2510 | /* But when user specify an valid SPI, transformation | ||
2511 | * supports both transport/tunnel mode + ESP/AH type. | ||
2512 | */ | ||
2513 | if ((x->props.mode == XFRM_MODE_TUNNEL) && (pkt_dev->spi != 0)) | ||
2514 | skb->_skb_refdst = (unsigned long)&pkt_dev->dst | SKB_DST_NOREF; | ||
2515 | |||
2516 | rcu_read_lock_bh(); | ||
2503 | err = x->outer_mode->output(x, skb); | 2517 | err = x->outer_mode->output(x, skb); |
2518 | rcu_read_unlock_bh(); | ||
2504 | if (err) { | 2519 | if (err) { |
2505 | XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTSTATEMODEERROR); | 2520 | XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTSTATEMODEERROR); |
2506 | goto error; | 2521 | goto error; |
@@ -3557,6 +3572,17 @@ static int pktgen_add_device(struct pktgen_thread *t, const char *ifname) | |||
3557 | #ifdef CONFIG_XFRM | 3572 | #ifdef CONFIG_XFRM |
3558 | pkt_dev->ipsmode = XFRM_MODE_TRANSPORT; | 3573 | pkt_dev->ipsmode = XFRM_MODE_TRANSPORT; |
3559 | pkt_dev->ipsproto = IPPROTO_ESP; | 3574 | pkt_dev->ipsproto = IPPROTO_ESP; |
3575 | |||
3576 | /* xfrm tunnel mode needs additional dst to extract outter | ||
3577 | * ip header protocol/ttl/id field, here creat a phony one. | ||
3578 | * instead of looking for a valid rt, which definitely hurting | ||
3579 | * performance under such circumstance. | ||
3580 | */ | ||
3581 | pkt_dev->dstops.family = AF_INET; | ||
3582 | pkt_dev->dst.dev = pkt_dev->odev; | ||
3583 | dst_init_metrics(&pkt_dev->dst, pktgen_dst_metrics, false); | ||
3584 | pkt_dev->dst.child = &pkt_dev->dst; | ||
3585 | pkt_dev->dst.ops = &pkt_dev->dstops; | ||
3560 | #endif | 3586 | #endif |
3561 | 3587 | ||
3562 | return add_dev_to_thread(t, pkt_dev); | 3588 | return add_dev_to_thread(t, pkt_dev); |