2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 06:15:47 +00:00
Commit Graph

16171 Commits

Author SHA1 Message Date
Darrell Ball
7d7ded7af7 odp-execute: Rename 'may_steal' to 'should_steal'.
Signed-off-by: Darrell Ball <dlu998@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2018-05-23 11:36:47 -07:00
Darrell Ball
a8ab588936 odp-execute: Correct and clarify 'steal' parameter.
Correct and clarify 'steal'/'may_steal' comments in
odp_execute_actions().

Reported-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Darrell Ball <dlu998@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2018-05-23 11:32:45 -07:00
Darrell Ball
49a832f7c9 tests: Make test result more predictable.
The test 'ofproto-dpif - in place modification (vlan)' fails often
due to miss handling. Hence, make it more predictable by specifying
that misses should just be dropped.

Signed-off-by: Darrell Ball <dlu998@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2018-05-23 11:31:24 -07:00
William Tu
5e720da59d erspan: fix invalid erspan version.
ERSPAN only support version 1 and 2.  When packets send to an erspan device
which does not have proper version number set, drop the packet.  In real
case, we observe multicast packets sent to the erspan pernet device,
erspan0, which does not have erspan version configured.

Without this patch, we observe warning message from ovs-vswitchd as below,
due to receive an malformed erspan packet:

odp_util|WARN|odp_tun_key_from_attr__ invalid erspan version

Reported-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: William Tu <u9012063@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2018-05-21 20:33:30 -07:00
Greg Rose
828677b26d gre: Resolve gre receive issues
On newer Linux kernels or on older kernels such as Red Hat that backport
from newer upstream Linux kernel releases the built-in gre kernel module
will interfere with OVS gre code in the receive path.  Fix this up by
placing the gre kernel code within the openvswitch driver so it will
not have to depend on the built-in gre kernel module.

Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: William Tu <u9012063@gmail.com>
2018-05-21 20:33:30 -07:00
Greg Rose
e1ededf45f rhel: Enable ERSPAN features for RHEL 7.x
Enable ERSPAN on RHEL 7.x

Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: William Tu <u9012063@gmail.com>
2018-05-21 20:33:30 -07:00
William Tu
c5b38fa191 erspan: set bso when truncated bit is set.
Before the patch, the erspan BSO bit (Bad/Short/Oversized) is not
handled.  BSO has 4 possible values:
  00 --> Good frame with no error, or unknown integrity
  11 --> Payload is a Bad Frame with CRC or Alignment Error
  01 --> Payload is a Short Frame
  10 --> Payload is an Oversized Frame

This patch set BSO to 01 when truncate is true.

Signed-off-by: William Tu <u9012063@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2018-05-21 20:33:30 -07:00
William Tu
f1bc8ecd1d erspan: auto detect truncated ipv6 packets.
Upstream commit:
    commit d5db21a3e6977dcb42cee3d16cd69901fa66510a
    Author: William Tu <u9012063@gmail.com>
    Date:   Fri May 11 05:49:47 2018 -0700

    erspan: auto detect truncated ipv6 packets.

    Currently the truncated bit is set only when 1) the mirrored packet
    is larger than mtu and 2) the ipv4 packet tot_len is larger than
    the actual skb->len.  This patch adds another case for detecting
    whether ipv6 packet is truncated or not, by checking the ipv6 header
    payload_len and the skb->len.

    Reported-by: Xiaoyan Jin <xiaoyanj@vmware.com>
    Signed-off-by: William Tu <u9012063@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: William Tu <u9012063@gmail.com>
Cc: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2018-05-21 20:33:30 -07:00
William Tu
bf6627087b ip6erspan: make sure enough headroom at xmit.
Upstream commit:
    commit e41c7c68ea771683cae5a7f81c268f38d7912ecb
    Author: William Tu <u9012063@gmail.com>
    Date:   Fri Mar 9 07:34:42 2018 -0800

    ip6erspan: make sure enough headroom at xmit.

    The patch adds skb_cow_header() to ensure enough headroom
    at ip6erspan_tunnel_xmit before pushing the erspan header
    to the skb.

    Signed-off-by: William Tu <u9012063@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Cc: William Tu <u9012063@gmail.com>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: William Tu <u9012063@gmail.com>
2018-05-21 20:33:30 -07:00
William Tu
8dc47fbd24 ip6erspan: improve error handling for erspan version number.
Upstream commit:
    commit d6aa71197ffcb68850bfebfc3fc160abe41df53b
    Author: William Tu <u9012063@gmail.com>
    Date:   Fri Mar 9 07:34:41 2018 -0800

    ip6erspan: improve error handling for erspan version number.

    When users fill in incorrect erspan version number through
    the struct erspan_metadata uapi, current code skips pushing
    the erspan header but continue pushing the gre header, which
    is incorrect.  The patch fixes it by returning error.

    Signed-off-by: William Tu <u9012063@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Cc: William Tu <u9012063@gmail.com>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: William Tu <u9012063@gmail.com>
2018-05-21 20:33:30 -07:00
William Tu
753f9bcd71 ip6gre: add erspan v2 to tunnel lookup
Upstream commit:
    commit 3b04caab81649a9e8d5375b919b6653d791951df
    Author: William Tu <u9012063@gmail.com>
    Date:   Fri Mar 9 07:34:40 2018 -0800

    ip6gre: add erspan v2 to tunnel lookup

    The patch adds the erspan v2 proto in ip6gre_tunnel_lookup
    so the erspan v2 tunnel can be found correctly.

    Signed-off-by: William Tu <u9012063@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Cc: William Tu <u9012063@gmail.com>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: William Tu <u9012063@gmail.com>
2018-05-21 20:33:30 -07:00
Greg Rose
068794b43f erspan: Add flow-based erspan options
The patch add supports for flow-based erspan options.
The erspan_ver, erspan_idx, erspan_dir, and erspan_hwid can be
set as "flow" so that its value is set by the openflow rule,
instead of statically configured at port creation time.

Signed-off-by: William Tu <u9012063@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2018-05-21 20:33:30 -07:00
Greg Rose
1c385f4972 lib/dpif-netlink: Fix miscompare of gre ports
In netdev_to_ovs_vport_type() it checks for netdev types matching
"gre" with a strstr().  This makes it match ip6gre as well and return
OVS_VPORT_TYPE_GRE, which is clearly wrong.

Move the usage of strstr() *after* all the exact matches with strcmp()
to avoid the problem permanently because when I added the ip6gre
type I ran into a very difficult to detect bug.

Cc: Ben Pfaff <blp@ovn.org>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: William Tu <u9012063@gmail.com>
2018-05-21 20:33:30 -07:00
Greg Rose
3b10ceeed1 ip6gre: Add ip6gre vport type
Add handlers for OVS_VPORT_TYPE_IP6GRE

Cc: Ben Pfaff <blp@ovn.org>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: William Tu <u9012063@gmail.com>
2018-05-21 20:33:30 -07:00
William Tu
c7d95a7c73 erspan: auto detect truncated packets.
Upstream commit:
    commit 1baf5ebf8954d9bff8fa4e7dd6c416a0cebdb9e2
    Author: William Tu <u9012063@gmail.com>
    Date:   Fri Apr 27 14:16:32 2018 -0700

    erspan: auto detect truncated packets.

    Currently the truncated bit is set only when the mirrored packet
    is larger than mtu.  For certain cases, the packet might already
    been truncated before sending to the erspan tunnel.  In this case,
    the patch detect whether the IP header's total length is larger
    than the actual skb->len.  If true, this indicated that the
    mirrored packet is truncated and set the erspan truncate bit.

    I tested the patch using bpf_skb_change_tail helper function to
    shrink the packet size and send to erspan tunnel.

    Reported-by: Xiaoyan Jin <xiaoyanj@vmware.com>
    Signed-off-by: William Tu <u9012063@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Cc: William Tu <u9012063@gmail.com>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: William Tu <u9012063@gmail.com>
2018-05-21 20:33:30 -07:00
William Tu
c6bbe82019 openvswitch: fix vport packet length check.
Upstream commit:
    commit 46e371f0e78a82186a83cbcb4f4b8850417c7dd5
    Author: William Tu <u9012063@gmail.com>
    Date:   Wed Mar 7 15:38:48 2018 -0800

    openvswitch: fix vport packet length check.

    When sending a packet to a tunnel device, the dev's hard_header_len
    could be larger than the skb->len in function packet_length().
    In the case of ip6gretap/erspan, hard_header_len = LL_MAX_HEADER + t_hlen,
    which is around 180, and an ARP packet sent to this tunnel has
    skb->len = 42.  This causes the 'unsign int length' to become super
    large because it is negative value, causing the later ovs_vport_send
    to drop it due to over-mtu size.  The patch fixes it by setting it to 0.

    Signed-off-by: William Tu <u9012063@gmail.com>
    Acked-by: Pravin B Shelar <pshelar@ovn.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Cc: William Tu <u9012063@gmail.com>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: William Tu <u9012063@gmail.com>
2018-05-21 20:33:30 -07:00
William Tu
98514eea21 erspan: add kernel datapath support
pass check, check-kernel (4.16-rc4), check-system-userspace

Signed-off-by: William Tu <u9012063@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2018-05-21 20:33:30 -07:00
William Tu
7dc18ae96d userspace: add erspan tunnel support.
ERSPAN is a tunneling protocol based on GRE tunnel.  The patch
add erspan tunnel support for ovs-vswitchd with userspace datapath.
Configuring erspan tunnel is similar to gre tunnel, but with
additional erspan's parameters.  Matching a flow on erspan's
metadata is also supported, see ovs-fields for more details.

Signed-off-by: William Tu <u9012063@gmail.com>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2018-05-21 20:33:30 -07:00
William Tu
0ffff49753 userspace: add gre sequence number support.
The patch adds support for gre sequence number.
Default is disable.  When enable with 'options:seq=true',
the outgoing gre packet will have its sequence number
incremented by one.

Signed-off-by: William Tu <u9012063@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2018-05-21 20:33:30 -07:00
William Tu
754f8acb45 netdev-native-tnl: refactor the tunnel push header.
The patch adds additional 'struct netdev *' to the
native tunnel's push_header() interface.  This is used
for later GRE sequence number support.

Signed-off-by: William Tu <u9012063@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2018-05-21 20:33:30 -07:00
William Tu
320326e9b3 datapath: add erspan version I and II support
Upstream commit:
    commit fc1372f89ffe1f58b589643b75f679e452350703
    Author: William Tu <u9012063@gmail.com>
    Date:   Thu Jan 25 13:20:11 2018 -0800

    openvswitch: add erspan version I and II support

    The patch adds support for openvswitch to configure erspan
    v1 and v2.  The OVS_TUNNEL_KEY_ATTR_ERSPAN_OPTS attr is added
    to uapi as a binary blob to support all ERSPAN v1 and v2's
    fields.  Note that Previous commit "openvswitch: Add erspan tunnel
    support." was reverted since it does not design properly.

    Signed-off-by: William Tu <u9012063@gmail.com>
    Acked-by: Pravin B Shelar <pshelar@ovn.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Cc: William Tu <u9012063@gmail.com>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: William Tu <u9012063@gmail.com>
2018-05-21 20:33:30 -07:00
William Tu
e6aa9dd86b compat: erspan: use bitfield instead of mask and offset
Upstream commit:
    commit c69de58ba84f480879de64571d9dae5102d10ed6
    Author: William Tu <u9012063@gmail.com>
    Date:   Thu Jan 25 13:20:09 2018 -0800

    net: erspan: use bitfield instead of mask and offset

    Originally the erspan fields are defined as a group into a __be16 field,
    and use mask and offset to access each field.  This is more costly due to
    calling ntohs/htons.  The patch changes it to use bitfields.

    Signed-off-by: William Tu <u9012063@gmail.com>
    Acked-by: Pravin B Shelar <pshelar@ovn.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Folds in the ip_gre portions of this commit.  Other portions of this
commit are included in a previous patch where it is called out.

Cc: William Tu <u9012063@gmail.com>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: William Tu <u9012063@gmail.com>
2018-05-21 20:33:30 -07:00
William Tu
e4120b10be datapath: erspan: introduce erspan v2 for ip_gre
Upstream commit:

    commit f551c91de262ba36b20c3ac19538afb4f4507441
    Author: William Tu <u9012063@gmail.com>
    Date:   Wed Dec 13 16:38:56 2017 -0800

    net: erspan: introduce erspan v2 for ip_gre

    The patch adds support for erspan version 2.  Not all features are
    supported in this patch.  The SGT (security group tag), GRA (timestamp
    granularity), FT (frame type) are set to fixed value.  Only hardware
    ID and direction are configurable.  Optional subheader is also not
    supported.

    Signed-off-by: William Tu <u9012063@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Includes some compatability layer adjustments and portions of this
commit were introduced earlier while pulling in ipv6 erspan.

Cc: William Tu <u9012063@gmail.com>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: William Tu <u9012063@gmail.com>
2018-05-21 20:33:30 -07:00
Greg Rose
c0e103c870 datapath: Use correct tunnel receive for ip6gre
During backports of ip6 gre I used ovs_ip_tunnel_rcv() for the
ip6gre_rcv() function but that is wrong because it processes ipv4
tunnels.  Use the correct backported ip6 tunnel receive in ip6
tunnel.c ip6_tnl_rcv().

Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: William Tu <u9012063@gmail.com>
2018-05-21 20:33:30 -07:00
Greg Rose
9c712eb4b2 datapath: Add dellink op to ip6gre and ip6erspan tap ops
Fix an oversight in the ip6gre_tap_ops and ip6erspan_tap_ops in
which the .dellink field was not initialized leading to bugs
when trying to remove and re-add those type of ports.

Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: William Tu <u9012063@gmail.com>
2018-05-21 20:33:29 -07:00
Greg Rose
c387d8177f compat: Add ipv6 GRE and IPV6 Tunneling
This patch backports upstream ipv6 GRE and tunneling into the OVS
OOT (Out of Tree) datapath drivers.  The primary reason for this
is to support the ERSPAN feature.

Because there is no previous history of ipv6 GRE and tunneling it is
not possible to exactly reproduce the history of all the files in
the patch.  The two newly added files - ip6_gre.c and ip6_tunnel.c -
are cut from whole cloth out of the upstream Linux 4.15 kernel and
then modified as necessary with compatibility layer fixups.
These two files already included parts of several other upstream
commits that also touched other upstream files.  As such, this
patch may incorporate parts or all of the following commits:

d350a82 net: erspan: create erspan metadata uapi header
c69de58 net: erspan: use bitfield instead of mask and offset
b423d13 net: erspan: fix use-after-free
214bb1c net: erspan: remove md NULL check
afb4c97 ip6_gre: fix potential memory leak in ip6erspan_rcv
50670b6 ip_gre: fix potential memory leak in erspan_rcv
a734321 ip6_gre: fix error path when ip6erspan_rcv failed
dd8d5b8 ip_gre: fix error path when erspan_rcv failed
293a199 ip6_gre: fix a pontential issue in ip6erspan_rcv
d91e8db5 net: erspan: reload pointer after pskb_may_pull
ae3e133 net: erspan: fix wrong return value
c05fad5 ip_gre: fix wrong return value of erspan_rcv
94d7d8f ip6_gre: add erspan v2 support
f551c91 net: erspan: introduce erspan v2 for ip_gre
1d7e2ed net: erspan: refactor existing erspan code
ef7baf5 ip6_gre: add ip6 erspan collect_md mode
5a963eb ip6_gre: Add ERSPAN native tunnel support
ceaa001 openvswitch: Add erspan tunnel support.
f192970 ip_gre: check packet length and mtu correctly in erspan tx
c84bed4 ip_gre: erspan device should keep dst
c122fda ip_gre: set tunnel hlen properly in erspan_tunnel_init
5513d08 ip_gre: check packet length and mtu correctly in erspan_xmit
935a974 ip_gre: get key from session_id correctly in erspan_rcv
1a66a83 gre: add collect_md mode to ERSPAN tunnel
84e54fe gre: introduce native tunnel support for ERSPAN

In cases where the listed commits also touched other source code
files then the patches are also listed separately within this
patch series.

Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: William Tu <u9012063@gmail.com>
2018-05-21 20:33:29 -07:00
Greg Rose
e987c48a6f compat: Fixups for some compile warnings and errors
A lot of code has been pulled in.  Fix it up to make sure it compiles
correctly.

Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: William Tu <u9012063@gmail.com>
2018-05-21 20:33:29 -07:00
Greg Rose
a620d46811 compat: Add #define for gre_handle_offloads
Fixes compile errors on some 4.x kernels.

Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: William Tu <u9012063@gmail.com>
2018-05-21 20:33:29 -07:00
Greg Rose
f62f550420 compat: Move function to header
tnl_flags_to_gre_flags is also needed in both ip_gre.c and gre.c on
some kernels.  Move it from ip_gre.c to the common header.

Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: William Tu <u9012063@gmail.com>
2018-05-21 20:33:29 -07:00
Xin Long
4a8a3521e1 ip_gre: remove the incorrect mtu limit for ipgre tap
Upstream commit:
    commit cfddd4c33c254954927942599d299b3865743146
    Author: Xin Long <lucien.xin@gmail.com>
    Date:   Mon Dec 18 14:24:35 2017 +0800

    ip_gre: remove the incorrect mtu limit for ipgre tap

    ipgre tap driver calls ether_setup(), after commit 61e84623ace3
    ("net: centralize net_device min/max MTU checking"), the range
    of mtu is [min_mtu, max_mtu], which is [68, 1500] by default.

    It causes the dev mtu of the ipgre tap device to not be greater
    than 1500, this limit value is not correct for ipgre tap device.

    Besides, it's .change_mtu already does the right check. So this
    patch is just to set max_mtu as 0, and leave the check to it's
    .change_mtu.

    Fixes: 61e84623ace3 ("net: centralize net_device min/max MTU checking")
    Reported-by: Jianlin Shi <jishi@redhat.com>
    Signed-off-by: Xin Long <lucien.xin@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Cc: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: William Tu <u9012063@gmail.com>
2018-05-21 20:33:29 -07:00
William Tu
e289f5e039 ip_gre: erspan: reload pointer after pskb_may_pull
Upstream commit:
    commit d91e8db5b629a3c8c81db4dc317a66c7b5591821
    Author: William Tu <u9012063@gmail.com>
    Date:   Fri Dec 15 14:27:44 2017 -0800

    net: erspan: reload pointer after pskb_may_pull

    pskb_may_pull() can change skb->data, so we need to re-load pkt_md
    and ershdr at the right place.

    Fixes: 94d7d8f29287 ("ip6_gre: add erspan v2 support")
    Fixes: f551c91de262 ("net: erspan: introduce erspan v2 for ip_gre")
    Signed-off-by: William Tu <u9012063@gmail.com>
    Cc: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Only the ip_gre portion of the upstream commit.  The ipv6 portion
is pulled in with later patch in series.

Cc: William Tu <u9012063@gmail.com>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: William Tu <u9012063@gmail.com>
2018-05-21 20:33:29 -07:00
Haishuang Yan
bf3eff8d15 ip_gre: fix wrong return value of erspan_rcv
Upstream commit:
    commit c05fad5713b81b049ec6ac4eb2d304030b1efdce
    Author: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
    Date:   Fri Dec 15 10:46:16 2017 +0800

    ip_gre: fix wrong return value of erspan_rcv

    If pskb_may_pull return failed, return PACKET_REJECT instead of -ENOMEM.

    Fixes: 84e54fe0a5ea ("gre: introduce native tunnel support for ERSPAN")
    Cc: William Tu <u9012063@gmail.com>
    Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
    Acked-by: William Tu <u9012063@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Cc:  Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: William Tu <u9012063@gmail.com>
2018-05-21 20:33:29 -07:00
William Tu
2829d39433 compat/erspan: refactor existing erspan code
Upstream commit:
    commit 1d7e2ed22f8d9171fa8b629754022f22115b3f03
    Author: William Tu <u9012063@gmail.com>
    Date:   Wed Dec 13 16:38:55 2017 -0800

    net: erspan: refactor existing erspan code

    The patch refactors the existing erspan implementation in order
    to support erspan version 2, which has additional metadata.  So, in
    stead of having one 'struct erspanhdr' holding erspan version 1,
    breaks it into 'struct erspan_base_hdr' and 'struct erspan_metadata'.

    Signed-off-by: William Tu <u9012063@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Partial of the upstream commit.  While doing backports it is pretty
much impossible to fully reconstitute all upstream commits but we're
doing our best.  Other parts of this commit are introduced in the
upcoming monster patch for ip6 gre support.

Cc: William Tu <u9012063@gmail.com>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: William Tu <u9012063@gmail.com>
2018-05-21 20:33:29 -07:00
William Tu
29a29457c6 ip_gre: Refactor the erspan tunnel code.
Upstream commit:
    commit a3222dc95ca751cdc5f6ac3c9b092b160b73ed9f
    Author: William Tu <u9012063@gmail.com>
    Date:   Thu Nov 30 11:51:27 2017 -0800

    ip_gre: Refector the erpsan tunnel code.

    Move two erspan functions to header file, erspan.h, so ipv6
    erspan implementation can use it.

    Signed-off-by: William Tu <u9012063@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Cc: William Tu <u9012063@gmail.com>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: William Tu <u9012063@gmail.com>
2018-05-21 20:33:26 -07:00
Xin Long
2ce53c0a48 ip_gre: erspan device should keep dst
Upstream commit:
    commit c84bed440e4e11a973e8c0254d0dfaccfca41fb0
    Author: Xin Long <lucien.xin@gmail.com>
    Date:   Sun Oct 1 22:00:56 2017 +0800

    ip_gre: erspan device should keep dst

    The patch 'ip_gre: ipgre_tap device should keep dst' fixed
    the issue ipgre_tap dev mtu couldn't be updated in tx path.

    The same fix is needed for erspan as well.

    Fixes: 84e54fe0a5ea ("gre: introduce native tunnel support for ERSPAN")
    Signed-off-by: Xin Long <lucien.xin@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Cc: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: William Tu <u9012063@gmail.com>
2018-05-21 20:17:40 -07:00
Xin Long
cd71b0d76e ip_gre: set tunnel hlen properly in erspan_tunnel_init
Upstream commit:
    commit c122fda271717f4fc618e0a31e833941fd5f1efd
    Author: Xin Long <lucien.xin@gmail.com>
    Date:   Sun Oct 1 22:00:55 2017 +0800

    ip_gre: set tunnel hlen properly in erspan_tunnel_init

    According to __gre_tunnel_init, tunnel->hlen should be set as the
    headers' length between inner packet and outer iphdr.

    It would be used especially to calculate a proper mtu when updating
    mtu in tnl_update_pmtu. Now without setting it, a bigger mtu value
    than expected would be updated, which hurts performance a lot.

    This patch is to fix it by setting tunnel->hlen with:
       tunnel->tun_hlen + tunnel->encap_hlen + sizeof(struct erspanhdr)

    Fixes: 84e54fe0a5ea ("gre: introduce native tunnel support for ERSPAN")
    Signed-off-by: Xin Long <lucien.xin@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Cc: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: William Tu <u9012063@gmail.com>
2018-05-21 20:17:37 -07:00
Xin Long
fdf44520b8 ip_gre: get key from session_id correctly in erspan_rcv
Upstream commit:
    commit 935a9749a36828af0e8be224a5cd4bc758112c34
    Author: Xin Long <lucien.xin@gmail.com>
    Date:   Sun Oct 1 22:00:53 2017 +0800

    ip_gre: get key from session_id correctly in erspan_rcv

    erspan only uses the first 10 bits of session_id as the key to look
    up the tunnel. But in erspan_rcv, it missed 'session_id & ID_MASK'
    when getting the key from session_id.

    If any other flag is also set in session_id in a packet, it would
    fail to find the tunnel due to incorrect key in erspan_rcv.

    This patch is to add 'session_id & ID_MASK' there and also remove
    the unnecessary variable session_id.

    Fixes: 84e54fe0a5ea ("gre: introduce native tunnel support for ERSPAN")
    Signed-off-by: Xin Long <lucien.xin@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Cc: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: William Tu <u9012063@gmail.com>
2018-05-21 20:17:34 -07:00
William Tu
4f53627e2a ip_gre: check packet length and mtu correctly in erspan tx
Upstream commit:
    commit f192970de860d3ab90aa9e2a22853201a57bde78
    Author: William Tu <u9012063@gmail.com>
    Date:   Thu Oct 5 12:07:12 2017 -0700

    ip_gre: check packet length and mtu correctly in erspan tx

    Similarly to early patch for erspan_xmit(), the ARPHDR_ETHER device
    is the length of the whole ether packet.  So skb->len should subtract
    the dev->hard_header_len.

    Fixes: 1a66a836da63 ("gre: add collect_md mode to ERSPAN tunnel")
    Fixes: 84e54fe0a5ea ("gre: introduce native tunnel support for ERSPAN")
    Signed-off-by: William Tu <u9012063@gmail.com>
    Cc: Xin Long <lucien.xin@gmail.com>
    Cc: David Laight <David.Laight@aculab.com>
    Reviewed-by: Xin Long <lucien.xin@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Cc: William Tu <u9012063@gmail.com>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: William Tu <u9012063@gmail.com>
2018-05-21 20:17:31 -07:00
William Tu
5bff8644a1 compat/gre: add collect_md mode
commit 1a66a836da630cd70f3639208da549b549ce576b
    Author: William Tu <u9012063@gmail.com>
    Date:   Fri Aug 25 09:21:28 2017 -0700

    gre: add collect_md mode to ERSPAN tunnel

    Similar to gre, vxlan, geneve, ipip tunnels, allow ERSPAN tunnels to
    operate in 'collect metadata' mode.  bpf_skb_[gs]et_tunnel_key() helpers
    can make use of it right away.  OVS can use it as well in the future.

    Signed-off-by: William Tu <u9012063@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

With some adjustments for compatibility layer.

Cc: William Tu <u9012063@gmail.com>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: William Tu <u9012063@gmail.com>
2018-05-21 20:17:27 -07:00
William Tu
d8433b88eb gre: refactor the gre_fb_xmit
Upstream commit:
    commit 862a03c35ed76c50a562f7406ad23315f7862642
    Author: William Tu <u9012063@gmail.com>
    Date:   Fri Aug 25 09:21:27 2017 -0700

    gre: refactor the gre_fb_xmit

    The patch refactors the gre_fb_xmit function, by creating
    prepare_fb_xmit function for later ERSPAN collect_md mode patch.

    Signed-off-by: William Tu <u9012063@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Only the prepare_fb_xmit() function is pulled in.  Compatibility
issues prevent the refactor of gre_fb_xmit() but we need the
prepare_fb_xmit() function for the subsequent patch.

Cc: William Tu <u9012063@gmail.com>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: William Tu <u9012063@gmail.com>
2018-05-21 20:17:25 -07:00
William Tu
f3c3183911 gre: fix goto statement typo
Upstream commit:
    commit e3d0328c76dde0b957f62f8c407b79f1d8fe3ef8
    Author: William Tu <u9012063@gmail.com>
    Date:   Tue Aug 22 17:04:05 2017 -0700

    gre: fix goto statement typo

    Fix typo: pnet_tap_faied.

    Signed-off-by: William Tu <u9012063@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Cc: William Tu <u9012063@gmail.com>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: William Tu <u9012063@gmail.com>
2018-05-21 20:17:21 -07:00
William Tu
8e53509cc6 gre: introduce native tunnel support for ERSPAN
Upstream commit:
    commit 84e54fe0a5eaed696dee4019c396f8396f5a908b
    Author: William Tu <u9012063@gmail.com>
    Date:   Tue Aug 22 09:40:28 2017 -0700

    gre: introduce native tunnel support for ERSPAN

    The patch adds ERSPAN type II tunnel support.  The implementation
    is based on the draft at [1].  One of the purposes is for Linux
    box to be able to receive ERSPAN monitoring traffic sent from
    the Cisco switch, by creating a ERSPAN tunnel device.
    In addition, the patch also adds ERSPAN TX, so Linux virtual
    switch can redirect monitored traffic to the ERSPAN tunnel device.
    The traffic will be encapsulated into ERSPAN and sent out.

    The implementation reuses tunnel key as ERSPAN session ID, and
    field 'erspan' as ERSPAN Index fields:
    ./ip link add dev ers11 type erspan seq key 100 erspan 123 \
    			local 172.16.1.200 remote 172.16.1.100

    To use the above device as ERSPAN receiver, configure
    Nexus 5000 switch as below:

    monitor session 100 type erspan-source
      erspan-id 123
      vrf default
      destination ip 172.16.1.200
      source interface Ethernet1/11 both
      source interface Ethernet1/12 both
      no shut
    monitor erspan origin ip-address 172.16.1.100 global

    [1] https://tools.ietf.org/html/draft-foschiano-erspan-01
    [2] iproute2 patch: http://marc.info/?l=linux-netdev&m=150306086924951&w=2
    [3] test script: http://marc.info/?l=linux-netdev&m=150231021807304&w=2

    Signed-off-by: William Tu <u9012063@gmail.com>
    Signed-off-by: Meenakshi Vohra <mvohra@vmware.com>
    Cc: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
    Cc: Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>

This commit also backports heavily from upstream gre, ip_gre and
ip_tunnel modules to support the necessary erspan ip gre
infrastructure as well as implementing a variety of compatability
layer changes for same support.

Cc: William Tu <u9012063@gmail.com>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: William Tu <u9012063@gmail.com>
2018-05-21 20:17:15 -07:00
Greg Rose
d97d7f77a9 compat: Remove unsupported kernel compat code
Anything less than 3.10 isn't supported since a couple of releases ago
so remove the dead code.

Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: William Tu <u9012063@gmail.com>
2018-05-21 20:17:04 -07:00
Justin Pettit
1d0dead5c4 ovsdb: Use new ovsdb_log_write_and_free().
Signed-off-by: Justin Pettit <jpettit@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
2018-05-17 13:01:59 -07:00
Ben Pfaff
fac4786a1b ofproto-dpif-xlate: Improve tracing through groups.
This makes it clear which buckets from a group are executed and why.

The update to nsh.at provides an example.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Justin Pettit <jpettit@ovn.org>
2018-05-17 08:16:08 -07:00
Ben Pfaff
e428148a1f ofp-print: Handle statistics more systematically.
ofp_to_string__() is supposed to call ofp_print_stats() for all kinds of
statistics, but it was only doing so haphazardly.  This commit makes it
systematic and in the process adds it to at least one case where it was
missing (and fixes up a test case).

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Justin Pettit <jpettit@ovn.org>
2018-05-17 08:16:08 -07:00
Ben Pfaff
e9c9481f3b ofp-group: Move formatting code for groups into ofp-group.
This does a better job of putting related code together.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Justin Pettit <jpettit@ovn.org>
2018-05-17 08:16:08 -07:00
Ben Pfaff
7b809df952 Add OpenFlow extensions for group support in OpenFlow 1.0.
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Justin Pettit <jpettit@ovn.org>
2018-05-17 08:16:06 -07:00
Ben Pfaff
720c104c93 ofp-group: Require watch_port or watch_group when parsing ff groups.
Fast failover buckets must have a watch_port or a watch_group (or both),
and ovs-vswitchd enforces this, but the bucket parsing code didn't check
it.  This meant that when it was omitted, the error messages were harder
to understand.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Justin Pettit <jpettit@ovn.org>
2018-05-17 08:09:21 -07:00
Ben Pfaff
a04e58881e ofproto-dpif-xlate: Simplify translation for groups.
Translation of groups had a lot of redundant code.  This commit eliminates
most of it.  It should also make it harder to accidentally reintroduce
the reference leak fixed in a previous commit.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Justin Pettit <jpettit@ovn.org>
2018-05-17 08:09:14 -07:00