forked from yyang13/ovs_nsh_patches
-
Notifications
You must be signed in to change notification settings - Fork 0
/
0007-Fix-ovs-dpdk-issues.patch
124 lines (112 loc) · 4.64 KB
/
0007-Fix-ovs-dpdk-issues.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
From f0055aeafda4fc1ff60d76e18805f6df0f3b7499 Mon Sep 17 00:00:00 2001
From: Yi Yang <[email protected]>
Date: Fri, 26 Aug 2016 09:21:20 +0800
Subject: [PATCH 7/8] Fix ovs dpdk issues
- Correct format_nsh error
- Add Ethernet header for the NSH packet decapsulated from VxLAN-gpe port
- Fix flow key to flow conversion issue for nsh
Signed-off-by: Yi Yang <[email protected]>
---
lib/dpif-netdev.c | 7 +++++--
lib/netdev-vport.c | 18 +++++++++++++++++-
lib/odp-util.c | 8 +++-----
lib/packets.c | 5 +++--
4 files changed, 28 insertions(+), 10 deletions(-)
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index d40cae4..31f80d4 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -1963,8 +1963,11 @@ dpif_netdev_flow_from_nlattrs(const struct nlattr *key, uint32_t key_len,
struct flow *flow)
{
odp_port_t in_port;
+ enum odp_key_fitness fitness;
+
+ fitness = odp_flow_key_to_flow_udpif(key, key_len, flow);
- if (odp_flow_key_to_flow_udpif(key, key_len, flow)) {
+ if (fitness) {
/* This should not happen: it indicates that odp_flow_key_from_flow()
* and odp_flow_key_to_flow() disagree on the acceptable form of a
* flow. Log the problem as an error, with enough details to enable
@@ -1976,7 +1979,7 @@ dpif_netdev_flow_from_nlattrs(const struct nlattr *key, uint32_t key_len,
ds_init(&s);
odp_flow_format(key, key_len, NULL, 0, NULL, &s, true);
- VLOG_ERR("internal error parsing flow key %s", ds_cstr(&s));
+ VLOG_ERR("internal error parsing flow key %s (%s)", ds_cstr(&s), odp_key_fitness_to_string(fitness));
ds_destroy(&s);
}
diff --git a/lib/netdev-vport.c b/lib/netdev-vport.c
index 67a020a..94f23d9 100644
--- a/lib/netdev-vport.c
+++ b/lib/netdev-vport.c
@@ -1309,7 +1309,6 @@ netdev_vxlan_pop_header(struct dp_packet *packet)
return EINVAL;
}
-
/* vxlan-gpe packets*/
flag = get_16aligned_be32(&vxh->vx_flags);
@@ -1332,6 +1331,23 @@ netdev_vxlan_pop_header(struct dp_packet *packet)
/* Drop the OAM packets */
if (gpe->oam_flag)
return EINVAL;
+
+ tnl->tun_id = htonll(ntohl(get_16aligned_be32(&vxh->vx_vni)) >> 8);
+ tnl->flags |= FLOW_TNL_F_KEY;
+
+ if (tnl->gpe_np == VXLAN_GPE_NP_NSH) {
+ /* Add a faked ethernet header which type is 0x894F, so the OVS
+ * can receive frame starting with ethernet header.
+ */
+ struct eth_header * encap_eth;
+ struct eth_header * eth = dp_packet_l2(packet);
+
+ memmove((char *)eth + hlen + VXLAN_HLEN - ENCAP_ETH_LEN, (char *)eth + hlen + VXLAN_HLEN + NSH_PUSH_TYPE1_HEADER_SIZE, 2 * ETH_ADDR_LEN);
+ dp_packet_reset_packet(packet, hlen + VXLAN_HLEN - ENCAP_ETH_LEN);
+ encap_eth = dp_packet_data(packet);
+ encap_eth->eth_type = htons(ETH_P_NSH);
+ } else
+ dp_packet_reset_packet(packet, hlen + VXLAN_HLEN);
} else {
if (flag != htonl(VXLAN_FLAGS) ||
(get_16aligned_be32(&vxh->vx_vni) & htonl(0xff))) {
diff --git a/lib/odp-util.c b/lib/odp-util.c
index 51f0545..0190d28 100644
--- a/lib/odp-util.c
+++ b/lib/odp-util.c
@@ -393,8 +393,8 @@ format_nsh(struct ds *ds, const struct ovs_action_push_nsh * nsh)
",nshc3=%"PRIu32",nshc4=%"PRIu32")",
eth_nsh_header->nsh_hdr.base.mdtype,
eth_nsh_header->nsh_hdr.base.proto,
- ntohl(eth_nsh_header->nsh_hdr.base.path_hdr << 8),
- ntohl(eth_nsh_header->nsh_hdr.base.path_hdr >> 24),
+ ntohl(eth_nsh_header->nsh_hdr.base.path_hdr) >> 8,
+ ntohl(eth_nsh_header->nsh_hdr.base.path_hdr) & 0xFF,
ntohl(eth_nsh_header->nsh_hdr.ctx.nshc1),
ntohl(eth_nsh_header->nsh_hdr.ctx.nshc2),
ntohl(eth_nsh_header->nsh_hdr.ctx.nshc3),
@@ -5413,9 +5413,7 @@ odp_flow_key_to_flow__(const struct nlattr *key, size_t key_len,
nsh_key = nl_attr_get(attrs[OVS_KEY_ATTR_NSH]);
put_nsh_key(nsh_key, flow);
- if (is_mask) {
- expected_attrs |= UINT64_C(1) << OVS_KEY_ATTR_NSH;
- }
+ expected_attrs |= UINT64_C(1) << OVS_KEY_ATTR_NSH;
}
/* Ethernet header. */
diff --git a/lib/packets.c b/lib/packets.c
index d314b2d..4c9a019 100644
--- a/lib/packets.c
+++ b/lib/packets.c
@@ -260,8 +260,9 @@ void
pop_nsh(struct dp_packet *packet)
{
if (ETH_NSH_TYPE1_HEADER_SIZE > dp_packet_size(packet)) {
- return;
- }
+ return;
+ }
+
dp_packet_reset_packet(packet, ETH_NSH_TYPE1_HEADER_SIZE);
}
--
2.1.0