[ovs-dev] [PATCH v1] ofproto: fix a typo for ttl in dpif_sflow_actions
From: Martin Zhang Signed-off-by: Martin Zhang --- ofproto/ofproto-dpif-sflow.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ofproto/ofproto-dpif-sflow.c b/ofproto/ofproto-dpif-sflow.c index 03bd763..9abaab6 100644 --- a/ofproto/ofproto-dpif-sflow.c +++ b/ofproto/ofproto-dpif-sflow.c @@ -1026,7 +1026,7 @@ sflow_read_set_action(const struct nlattr *attr, sflow_actions->tunnel.ip_tos = key->ipv4_tos; } if (key->ipv4_ttl) { -sflow_actions->tunnel.ip_tos = key->ipv4_ttl; +sflow_actions->tunnel.ip_ttl = key->ipv4_ttl; } } break; -- 1.8.3.1 ___ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev
[ovs-dev] [PATCH v3] odp-util: calc checksum of ip hdr for tunnel encap
From: Martin Zhang V2: fix warning V3: replace tab with spaces Signed-off-by: Martin Zhang --- lib/odp-util.c | 10 +++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/odp-util.c b/lib/odp-util.c index fe59a56..36c6c3b 100644 --- a/lib/odp-util.c +++ b/lib/odp-util.c @@ -44,6 +44,7 @@ #include "openvswitch/vlog.h" #include "openvswitch/match.h" #include "odp-netlink-macros.h" +#include "csum.h" VLOG_DEFINE_THIS_MODULE(odp_util); @@ -1482,7 +1483,7 @@ ovs_parse_tnl_push(const char *s, struct ovs_action_push_tnl *data) struct gre_base_hdr *greh; struct erspan_base_hdr *ersh; struct erspan_md2 *md2; -uint16_t gre_proto, gre_flags, dl_type, udp_src, udp_dst, csum, sid; +uint16_t gre_proto, gre_flags, dl_type, udp_src, udp_dst, udp_csum, sid; ovs_be32 sip, dip; uint32_t tnl_type = 0, header_len = 0, ip_len = 0, erspan_idx = 0; void *l3, *l4; @@ -1516,6 +1517,7 @@ ovs_parse_tnl_push(const char *s, struct ovs_action_push_tnl *data) if (eth->eth_type == htons(ETH_TYPE_IP)) { /* IPv4 */ uint16_t ip_frag_off; +memset(ip, 0, sizeof(*ip)); if (!ovs_scan_len(s, , "ipv4(src="IP_SCAN_FMT",dst="IP_SCAN_FMT",proto=%"SCNi8 ",tos=%"SCNi8",ttl=%"SCNi8",frag=0x%"SCNx16"),", IP_SCAN_ARGS(), @@ -1529,6 +1531,7 @@ ovs_parse_tnl_push(const char *s, struct ovs_action_push_tnl *data) ip->ip_frag_off = htons(ip_frag_off); ip->ip_ihl_ver = IP_IHL_VER(5, 4); ip_len = sizeof *ip; +ip->ip_csum = csum(ip, ip_len); } else { char sip6_s[IPV6_SCAN_LEN + 1]; char dip6_s[IPV6_SCAN_LEN + 1]; @@ -1557,13 +1560,13 @@ ovs_parse_tnl_push(const char *s, struct ovs_action_push_tnl *data) udp = (struct udp_header *) l4; greh = (struct gre_base_hdr *) l4; if (ovs_scan_len(s, , "udp(src=%"SCNi16",dst=%"SCNi16",csum=0x%"SCNx16"),", - _src, _dst, )) { + _src, _dst, _csum)) { uint32_t vx_flags, vni; udp->udp_src = htons(udp_src); udp->udp_dst = htons(udp_dst); udp->udp_len = 0; -udp->udp_csum = htons(csum); +udp->udp_csum = htons(udp_csum); if (ovs_scan_len(s, , "vxlan(flags=0x%"SCNx32",vni=0x%"SCNx32"))", _flags, )) { @@ -1629,6 +1632,7 @@ ovs_parse_tnl_push(const char *s, struct ovs_action_push_tnl *data) ovs_16aligned_be32 *options = (ovs_16aligned_be32 *) (greh + 1); if (greh->flags & htons(GRE_CSUM)) { +uint16_t csum; if (!ovs_scan_len(s, , ",csum=0x%"SCNx16, )) { return -EINVAL; } -- 1.8.3.1 ___ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev
[ovs-dev] [PATCH v2] odp-util: calc checksum of ip hdr for tunnel encap
From: Martin Zhang Signed-off-by: Martin Zhang V2: fix compile warning Signed-off-by: Martin Zhang --- lib/odp-util.c | 10 +++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/odp-util.c b/lib/odp-util.c index fe59a56..29ffd6d 100644 --- a/lib/odp-util.c +++ b/lib/odp-util.c @@ -44,6 +44,7 @@ #include "openvswitch/vlog.h" #include "openvswitch/match.h" #include "odp-netlink-macros.h" +#include "csum.h" VLOG_DEFINE_THIS_MODULE(odp_util); @@ -1482,7 +1483,7 @@ ovs_parse_tnl_push(const char *s, struct ovs_action_push_tnl *data) struct gre_base_hdr *greh; struct erspan_base_hdr *ersh; struct erspan_md2 *md2; -uint16_t gre_proto, gre_flags, dl_type, udp_src, udp_dst, csum, sid; +uint16_t gre_proto, gre_flags, dl_type, udp_src, udp_dst, udp_csum, sid; ovs_be32 sip, dip; uint32_t tnl_type = 0, header_len = 0, ip_len = 0, erspan_idx = 0; void *l3, *l4; @@ -1516,6 +1517,7 @@ ovs_parse_tnl_push(const char *s, struct ovs_action_push_tnl *data) if (eth->eth_type == htons(ETH_TYPE_IP)) { /* IPv4 */ uint16_t ip_frag_off; + memset(ip, 0, sizeof(*ip)); if (!ovs_scan_len(s, , "ipv4(src="IP_SCAN_FMT",dst="IP_SCAN_FMT",proto=%"SCNi8 ",tos=%"SCNi8",ttl=%"SCNi8",frag=0x%"SCNx16"),", IP_SCAN_ARGS(), @@ -1529,6 +1531,7 @@ ovs_parse_tnl_push(const char *s, struct ovs_action_push_tnl *data) ip->ip_frag_off = htons(ip_frag_off); ip->ip_ihl_ver = IP_IHL_VER(5, 4); ip_len = sizeof *ip; + ip->ip_csum = csum(ip, ip_len); } else { char sip6_s[IPV6_SCAN_LEN + 1]; char dip6_s[IPV6_SCAN_LEN + 1]; @@ -1557,13 +1560,13 @@ ovs_parse_tnl_push(const char *s, struct ovs_action_push_tnl *data) udp = (struct udp_header *) l4; greh = (struct gre_base_hdr *) l4; if (ovs_scan_len(s, , "udp(src=%"SCNi16",dst=%"SCNi16",csum=0x%"SCNx16"),", - _src, _dst, )) { + _src, _dst, _csum)) { uint32_t vx_flags, vni; udp->udp_src = htons(udp_src); udp->udp_dst = htons(udp_dst); udp->udp_len = 0; -udp->udp_csum = htons(csum); +udp->udp_csum = htons(udp_csum); if (ovs_scan_len(s, , "vxlan(flags=0x%"SCNx32",vni=0x%"SCNx32"))", _flags, )) { @@ -1629,6 +1632,7 @@ ovs_parse_tnl_push(const char *s, struct ovs_action_push_tnl *data) ovs_16aligned_be32 *options = (ovs_16aligned_be32 *) (greh + 1); if (greh->flags & htons(GRE_CSUM)) { +uint16_t csum; if (!ovs_scan_len(s, , ",csum=0x%"SCNx16, )) { return -EINVAL; } -- 1.8.3.1 ___ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev
[ovs-dev] [PATCH v1] odp-util: calc checksum of ip hdr for tunnel encap
From: Martin Zhang When parse tnl_push, if IPv4 is used, we forget to fill the ipv4 checksum fields. In the patch: csum has been used as a variable, so we neeed rename it to udp_csum. Signed-off-by: Martin Zhang Signed-off-by: Dujie --- lib/odp-util.c | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/odp-util.c b/lib/odp-util.c index fe59a56..fe539ec 100644 --- a/lib/odp-util.c +++ b/lib/odp-util.c @@ -1482,7 +1482,7 @@ ovs_parse_tnl_push(const char *s, struct ovs_action_push_tnl *data) struct gre_base_hdr *greh; struct erspan_base_hdr *ersh; struct erspan_md2 *md2; -uint16_t gre_proto, gre_flags, dl_type, udp_src, udp_dst, csum, sid; +uint16_t gre_proto, gre_flags, dl_type, udp_src, udp_dst, udp_csum, sid; ovs_be32 sip, dip; uint32_t tnl_type = 0, header_len = 0, ip_len = 0, erspan_idx = 0; void *l3, *l4; @@ -1516,6 +1516,7 @@ ovs_parse_tnl_push(const char *s, struct ovs_action_push_tnl *data) if (eth->eth_type == htons(ETH_TYPE_IP)) { /* IPv4 */ uint16_t ip_frag_off; + memset(ip, 0, sizeof(*ip)); if (!ovs_scan_len(s, , "ipv4(src="IP_SCAN_FMT",dst="IP_SCAN_FMT",proto=%"SCNi8 ",tos=%"SCNi8",ttl=%"SCNi8",frag=0x%"SCNx16"),", IP_SCAN_ARGS(), @@ -1529,6 +1530,7 @@ ovs_parse_tnl_push(const char *s, struct ovs_action_push_tnl *data) ip->ip_frag_off = htons(ip_frag_off); ip->ip_ihl_ver = IP_IHL_VER(5, 4); ip_len = sizeof *ip; + ip->ip_csum = csum(ip, ip_len); } else { char sip6_s[IPV6_SCAN_LEN + 1]; char dip6_s[IPV6_SCAN_LEN + 1]; @@ -1557,13 +1559,13 @@ ovs_parse_tnl_push(const char *s, struct ovs_action_push_tnl *data) udp = (struct udp_header *) l4; greh = (struct gre_base_hdr *) l4; if (ovs_scan_len(s, , "udp(src=%"SCNi16",dst=%"SCNi16",csum=0x%"SCNx16"),", - _src, _dst, )) { + _src, _dst, _csum)) { uint32_t vx_flags, vni; udp->udp_src = htons(udp_src); udp->udp_dst = htons(udp_dst); udp->udp_len = 0; -udp->udp_csum = htons(csum); +udp->udp_csum = htons(udp_csum); if (ovs_scan_len(s, , "vxlan(flags=0x%"SCNx32",vni=0x%"SCNx32"))", _flags, )) { @@ -1629,6 +1631,7 @@ ovs_parse_tnl_push(const char *s, struct ovs_action_push_tnl *data) ovs_16aligned_be32 *options = (ovs_16aligned_be32 *) (greh + 1); if (greh->flags & htons(GRE_CSUM)) { +uint16_t csum; if (!ovs_scan_len(s, , ",csum=0x%"SCNx16, )) { return -EINVAL; } -- 1.8.3.1 ___ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev
[ovs-dev] [PATCH] odp-util: fill IPv4 ver and head length for tnl_push
From: Martin Zhang When parse tnl_push, if IPv4 is used, we forget to fill the ipv4 version and ip header length fields. so there is a wrong ip header in the header of "struct ovs_action_push_tnl", which will caused wrong packdet sent by dpcl. test command: ovs-appctl dpctl/add-flow "in_port(1),eth_type(0x0800),ipv4(dst=9.9.9.6)" \ "tnl_push(tnl_port(2),header(size=50,type=4,eth(dst=08:00:27:2e:87:0d,src=98:03:9b:c6:d1:7c,dl_type=0x0800), \ ipv4(src=10.97.240.147,dst=10.96.74.33,proto=17,tos=0,ttl=64,frag=0x4000), \ udp(src=0,dst=4789,csum=0x0),vxlan(flags=0x800,vni=0x270f)),out_port(3)),4" Signed-off-by: Martin Zhang Signed-off-by: Dujie --- lib/odp-util.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/odp-util.c b/lib/odp-util.c index 84ea4c1..fe59a56 100644 --- a/lib/odp-util.c +++ b/lib/odp-util.c @@ -1527,6 +1527,7 @@ ovs_parse_tnl_push(const char *s, struct ovs_action_push_tnl *data) put_16aligned_be32(>ip_src, sip); put_16aligned_be32(>ip_dst, dip); ip->ip_frag_off = htons(ip_frag_off); +ip->ip_ihl_ver = IP_IHL_VER(5, 4); ip_len = sizeof *ip; } else { char sip6_s[IPV6_SCAN_LEN + 1]; -- 1.8.3.1 ___ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev