Extend sFlow agent to report tunnel and MPLS structures
authorNeil McKee <neil.mckee@inmon.com>
Sat, 18 Jul 2015 04:37:02 +0000 (21:37 -0700)
committerBen Pfaff <blp@nicira.com>
Tue, 21 Jul 2015 21:19:04 +0000 (14:19 -0700)
commit7321bda384c366ae36bbca445f235a65d8f2b1f8
tree6f76129ee3fb02512389632a3b4a2d82b63ad7ab
parent4b8df0378747a83ec2478ded1e9cefe64d6a9f86
Extend sFlow agent to report tunnel and MPLS structures

Packets are still sampled at ingress only, so the egress
tunnel and/or MPLS structures are only included when there is just 1 output
port.  The actions are either provided by the datapath in the sample upcall
or looked up in the userspace cache.  The former is preferred because it is
more reliable and does not present any new demands or constraints on the
userspace cache, however the code falls back on the userspace lookup so that
this solution can work with existing kernel datapath modules. If the lookup
fails it is not critical: the compiled user-action-cookie is still available
and provides the essential output port and output VLAN forwarding information
just as before.

The openvswitch actions can express almost any tunneling/mangling so the only
totally faithful representation would be to somehow encode the whole list of
flow actions in the sFlow output.  However the standard sFlow tunnel structures
can express most common real-world scenarios, so in parsing the actions we
look for those and skip the encoding if we see anything unusual. For example,
a single set(tunnel()) or tnl_push() is interpreted,  but if a second such
action is encountered then the egress tunnel reporting is suppressed.

The sFlow standard allows "best effort" encoding so that if a field is not
knowable or too onerous to look up then it can be left out. This is often
the case for the layer-4 source port or even the src ip address of a tunnel.
The assumption is that monitoring is enabled everywhere so a missing field
can typically be seen at ingress to the next switch in the path.

This patch also adds unit tests to check the sFlow encoding of set(tunnel()),
tnl_push() and push_mpls() actions.

The netlink attribute to request that actions be included in the upcall
from the datapath is inserted for sFlow sampling only.  To make that option
be explicit would require further changes to the printing and parsing of
actions in lib/odp-util.c, and to scripts in the test suite.

Further enhancements to report on 802.1AD QinQ, 64-bit tunnel IDs, and NAT
transformations can follow in future patches that make only incremental
changes.

Signed-off-by: Neil McKee <neil.mckee@inmon.com>
[blp@nicira.com made stylistic and semantic changes]
Signed-off-by: Ben Pfaff <blp@nicira.com>
13 files changed:
NEWS
include/sparse/netinet/in.h
lib/dpif-netlink.c
lib/dpif.h
lib/odp-util.c
lib/odp-util.h
ofproto/ofproto-dpif-sflow.c
ofproto/ofproto-dpif-sflow.h
ofproto/ofproto-dpif-upcall.c
ofproto/ofproto-dpif-xlate.c
tests/odp.at
tests/ofproto-dpif.at
tests/test-sflow.c