diff mbox series

[ovs-dev,v2] odp-util: calc checksum of ip hdr for tunnel encap

Message ID 1569547567-2901-1-git-send-email-martinbj2008@gmail.com
State Superseded
Headers show
Series [ovs-dev,v2] odp-util: calc checksum of ip hdr for tunnel encap | expand

Commit Message

Martin Zhang Sept. 27, 2019, 1:26 a.m. UTC
From: Martin Zhang <martinbj2008@gmail.com>

Signed-off-by: Martin Zhang <martinbj2008@gmail.com>

V2: fix compile warning

Signed-off-by: Martin Zhang <martinbj2008@gmail.com>
---
 lib/odp-util.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

Comments

0-day Robot Sept. 27, 2019, 1:58 a.m. UTC | #1
Bleep bloop.  Greetings Martin Zhang, I am a robot and I have tried out your patch.
Thanks for your contribution.

I encountered some error that I wasn't expecting.  See the details below.


checkpatch:
WARNING: Line has non-spaces leading whitespace
#40 FILE: lib/odp-util.c:1527:
	memset(ip, 0, sizeof(*ip));

WARNING: Line has non-spaces leading whitespace
#48 FILE: lib/odp-util.c:1541:
	ip->ip_csum = csum(ip, ip_len);

Lines checked: 78, Warnings: 2, Errors: 0


build:
mv tests/ovsdb-cluster-testsuite.tmp tests/ovsdb-cluster-testsuite
\
{ sed -n -e '/%AUTHORS%/q' -e p < ./debian/copyright.in;   \
  sed '34,/^$/d' ./AUTHORS.rst |			   \
	sed -n -e '/^$/q' -e 's/^/  /p';			   \
  sed -e '34,/%AUTHORS%/d' ./debian/copyright.in;	   \
} > debian/copyright
(printf '\043 Generated automatically -- do not modify!    -*- buffer-read-only: t -*-\n' && sed -e 's,[@]VERSION[@],2.12.90,g') < ./rhel/openvswitch-dkms.spec.in > openvswitch-dkms.spec.tmp || exit 1; if cmp -s openvswitch-dkms.spec.tmp rhel/openvswitch-dkms.spec; then touch rhel/openvswitch-dkms.spec; rm openvswitch-dkms.spec.tmp; else mv openvswitch-dkms.spec.tmp rhel/openvswitch-dkms.spec; fi
(printf '\043 Generated automatically -- do not modify!    -*- buffer-read-only: t -*-\n' && sed -e 's,[@]VERSION[@],2.12.90,g') < ./rhel/kmod-openvswitch-rhel6.spec.in > kmod-openvswitch-rhel6.spec.tmp || exit 1; if cmp -s kmod-openvswitch-rhel6.spec.tmp rhel/kmod-openvswitch-rhel6.spec; then touch rhel/kmod-openvswitch-rhel6.spec; rm kmod-openvswitch-rhel6.spec.tmp; else mv kmod-openvswitch-rhel6.spec.tmp rhel/kmod-openvswitch-rhel6.spec; fi
(printf '\043 Generated automatically -- do not modify!    -*- buffer-read-only: t -*-\n' && sed -e 's,[@]VERSION[@],2.12.90,g') < ./rhel/openvswitch-kmod-fedora.spec.in > openvswitch-kmod-fedora.spec.tmp || exit 1; if cmp -s openvswitch-kmod-fedora.spec.tmp rhel/openvswitch-kmod-fedora.spec; then touch rhel/openvswitch-kmod-fedora.spec; rm openvswitch-kmod-fedora.spec.tmp; else mv openvswitch-kmod-fedora.spec.tmp rhel/openvswitch-kmod-fedora.spec; fi
(printf '\043 Generated automatically -- do not modify!    -*- buffer-read-only: t -*-\n' && sed -e 's,[@]VERSION[@],2.12.90,g') < ./rhel/openvswitch.spec.in > openvswitch.spec.tmp || exit 1; if cmp -s openvswitch.spec.tmp rhel/openvswitch.spec; then touch rhel/openvswitch.spec; rm openvswitch.spec.tmp; else mv openvswitch.spec.tmp rhel/openvswitch.spec; fi
(printf '\043 Generated automatically -- do not modify!    -*- buffer-read-only: t -*-\n' && sed -e 's,[@]VERSION[@],2.12.90,g') < ./rhel/openvswitch-fedora.spec.in > openvswitch-fedora.spec.tmp || exit 1; if cmp -s openvswitch-fedora.spec.tmp rhel/openvswitch-fedora.spec; then touch rhel/openvswitch-fedora.spec; rm openvswitch-fedora.spec.tmp; else mv openvswitch-fedora.spec.tmp rhel/openvswitch-fedora.spec; fi
(printf '\043 Generated automatically -- do not modify!    -*- buffer-read-only: t -*-\n' && sed -e 's,[@]VERSION[@],2.12.90,g') \
	< ./xenserver/openvswitch-xen.spec.in > openvswitch-xen.spec.tmp || exit 1; \
if cmp -s openvswitch-xen.spec.tmp xenserver/openvswitch-xen.spec; then touch xenserver/openvswitch-xen.spec; rm openvswitch-xen.spec.tmp; else mv openvswitch-xen.spec.tmp xenserver/openvswitch-xen.spec; fi
make[3]: Entering directory `/var/lib/jenkins/jobs/upstream_build_from_pw/workspace/datapath'
make[3]: Leaving directory `/var/lib/jenkins/jobs/upstream_build_from_pw/workspace/datapath'
lib/odp-util.c
See above for files that use tabs for indentation.
Please use spaces instead.
make[2]: *** [check-tabs] Error 1
make[2]: Leaving directory `/var/lib/jenkins/jobs/upstream_build_from_pw/workspace'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/var/lib/jenkins/jobs/upstream_build_from_pw/workspace'
make: *** [all] Error 2


Please check this out.  If you feel there has been an error, please email aconole@redhat.com

Thanks,
0-day Robot
Ben Pfaff Sept. 27, 2019, 4:38 p.m. UTC | #2
Hi Martin, please fix the problems reported by the robot.

Thanks,

Ben.

On Thu, Sep 26, 2019 at 09:58:22PM -0400, 0-day Robot wrote:
> Bleep bloop.  Greetings Martin Zhang, I am a robot and I have tried out your patch.
> Thanks for your contribution.
> 
> I encountered some error that I wasn't expecting.  See the details below.
> 
> 
> checkpatch:
> WARNING: Line has non-spaces leading whitespace
> #40 FILE: lib/odp-util.c:1527:
> 	memset(ip, 0, sizeof(*ip));
> 
> WARNING: Line has non-spaces leading whitespace
> #48 FILE: lib/odp-util.c:1541:
> 	ip->ip_csum = csum(ip, ip_len);
> 
> Lines checked: 78, Warnings: 2, Errors: 0
> 
> 
> build:
> mv tests/ovsdb-cluster-testsuite.tmp tests/ovsdb-cluster-testsuite
> \
> { sed -n -e '/%AUTHORS%/q' -e p < ./debian/copyright.in;   \
>   sed '34,/^$/d' ./AUTHORS.rst |			   \
> 	sed -n -e '/^$/q' -e 's/^/  /p';			   \
>   sed -e '34,/%AUTHORS%/d' ./debian/copyright.in;	   \
> } > debian/copyright
> (printf '\043 Generated automatically -- do not modify!    -*- buffer-read-only: t -*-\n' && sed -e 's,[@]VERSION[@],2.12.90,g') < ./rhel/openvswitch-dkms.spec.in > openvswitch-dkms.spec.tmp || exit 1; if cmp -s openvswitch-dkms.spec.tmp rhel/openvswitch-dkms.spec; then touch rhel/openvswitch-dkms.spec; rm openvswitch-dkms.spec.tmp; else mv openvswitch-dkms.spec.tmp rhel/openvswitch-dkms.spec; fi
> (printf '\043 Generated automatically -- do not modify!    -*- buffer-read-only: t -*-\n' && sed -e 's,[@]VERSION[@],2.12.90,g') < ./rhel/kmod-openvswitch-rhel6.spec.in > kmod-openvswitch-rhel6.spec.tmp || exit 1; if cmp -s kmod-openvswitch-rhel6.spec.tmp rhel/kmod-openvswitch-rhel6.spec; then touch rhel/kmod-openvswitch-rhel6.spec; rm kmod-openvswitch-rhel6.spec.tmp; else mv kmod-openvswitch-rhel6.spec.tmp rhel/kmod-openvswitch-rhel6.spec; fi
> (printf '\043 Generated automatically -- do not modify!    -*- buffer-read-only: t -*-\n' && sed -e 's,[@]VERSION[@],2.12.90,g') < ./rhel/openvswitch-kmod-fedora.spec.in > openvswitch-kmod-fedora.spec.tmp || exit 1; if cmp -s openvswitch-kmod-fedora.spec.tmp rhel/openvswitch-kmod-fedora.spec; then touch rhel/openvswitch-kmod-fedora.spec; rm openvswitch-kmod-fedora.spec.tmp; else mv openvswitch-kmod-fedora.spec.tmp rhel/openvswitch-kmod-fedora.spec; fi
> (printf '\043 Generated automatically -- do not modify!    -*- buffer-read-only: t -*-\n' && sed -e 's,[@]VERSION[@],2.12.90,g') < ./rhel/openvswitch.spec.in > openvswitch.spec.tmp || exit 1; if cmp -s openvswitch.spec.tmp rhel/openvswitch.spec; then touch rhel/openvswitch.spec; rm openvswitch.spec.tmp; else mv openvswitch.spec.tmp rhel/openvswitch.spec; fi
> (printf '\043 Generated automatically -- do not modify!    -*- buffer-read-only: t -*-\n' && sed -e 's,[@]VERSION[@],2.12.90,g') < ./rhel/openvswitch-fedora.spec.in > openvswitch-fedora.spec.tmp || exit 1; if cmp -s openvswitch-fedora.spec.tmp rhel/openvswitch-fedora.spec; then touch rhel/openvswitch-fedora.spec; rm openvswitch-fedora.spec.tmp; else mv openvswitch-fedora.spec.tmp rhel/openvswitch-fedora.spec; fi
> (printf '\043 Generated automatically -- do not modify!    -*- buffer-read-only: t -*-\n' && sed -e 's,[@]VERSION[@],2.12.90,g') \
> 	< ./xenserver/openvswitch-xen.spec.in > openvswitch-xen.spec.tmp || exit 1; \
> if cmp -s openvswitch-xen.spec.tmp xenserver/openvswitch-xen.spec; then touch xenserver/openvswitch-xen.spec; rm openvswitch-xen.spec.tmp; else mv openvswitch-xen.spec.tmp xenserver/openvswitch-xen.spec; fi
> make[3]: Entering directory `/var/lib/jenkins/jobs/upstream_build_from_pw/workspace/datapath'
> make[3]: Leaving directory `/var/lib/jenkins/jobs/upstream_build_from_pw/workspace/datapath'
> lib/odp-util.c
> See above for files that use tabs for indentation.
> Please use spaces instead.
> make[2]: *** [check-tabs] Error 1
> make[2]: Leaving directory `/var/lib/jenkins/jobs/upstream_build_from_pw/workspace'
> make[1]: *** [all-recursive] Error 1
> make[1]: Leaving directory `/var/lib/jenkins/jobs/upstream_build_from_pw/workspace'
> make: *** [all] Error 2
> 
> 
> Please check this out.  If you feel there has been an error, please email aconole@redhat.com
> 
> Thanks,
> 0-day Robot
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
diff mbox series

Patch

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, &n, "ipv4(src="IP_SCAN_FMT",dst="IP_SCAN_FMT",proto=%"SCNi8
                           ",tos=%"SCNi8",ttl=%"SCNi8",frag=0x%"SCNx16"),",
                           IP_SCAN_ARGS(&sip),
@@ -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, &n, "udp(src=%"SCNi16",dst=%"SCNi16",csum=0x%"SCNx16"),",
-                     &udp_src, &udp_dst, &csum)) {
+                     &udp_src, &udp_dst, &udp_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, &n, "vxlan(flags=0x%"SCNx32",vni=0x%"SCNx32"))",
                          &vx_flags, &vni)) {
@@ -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, &n, ",csum=0x%"SCNx16, &csum)) {
                 return -EINVAL;
             }