No objections. Sounds useful for testing, and for situations where the agent-address selection has been made by a higher controller. Just one question: it seems like it is only IPv4: can an IPv6 agent-address be configured this way too?
I'll admit to this triggering bad memories of a situation when two switches were sending sFlow using each other's agent address, so perhaps a warning not to use this "manually" would be appropriate? ------ Neil McKee InMon Corp. http://www.inmon.com On Sat, Mar 31, 2018 at 5:12 PM, Ben Pfaff <[email protected]> wrote: > At least for testing purposes, and perhaps in production, it is useful to > be able to fix the agent IP address directly, rather that indirecting it > through a device name or the routing table. > > This commit uses this feature to fix the agent IP address used in the unit > tests. This will be particularly useful in an upcoming commit that > disables the use of the system routing table in the unit tests, to make > the tests' results independent of the host's routes. > > CC: Neil McKee <[email protected]> > Signed-off-by: Ben Pfaff <[email protected]> > --- > ofproto/ofproto-dpif-sflow.c | 3 ++- > tests/ofproto-dpif.at | 8 ++++---- > vswitchd/vswitch.xml | 25 ++++++++++++++++++------- > 3 files changed, 24 insertions(+), 12 deletions(-) > > diff --git a/ofproto/ofproto-dpif-sflow.c b/ofproto/ofproto-dpif-sflow.c > index 60e1b4e0a661..5d8c0e19f8e3 100644 > --- a/ofproto/ofproto-dpif-sflow.c > +++ b/ofproto/ofproto-dpif-sflow.c > @@ -453,7 +453,8 @@ sflow_choose_agent_address(const char *agent_device, > agent_addr->type = SFLADDRESSTYPE_IP_V4; > > if (agent_device) { > - if (!netdev_get_in4_by_name(agent_device, &in4)) { > + if (!netdev_get_in4_by_name(agent_device, &in4) > + || !lookup_ip(agent_device, &in4)) { > goto success; > } > } > diff --git a/tests/ofproto-dpif.at b/tests/ofproto-dpif.at > index d2058eddd3eb..60f28e2a08dd 100644 > --- a/tests/ofproto-dpif.at > +++ b/tests/ofproto-dpif.at > @@ -6333,7 +6333,7 @@ ovs-vsctl \ > set Interface p1 options:ifindex=1003 -- \ > set Bridge br0 sflow=@sf -- \ > --id=@sf create sflow targets=\"127.0.0.1:$SFLOW_PORT\" \ > - header=128 sampling=1 polling=1 > + header=128 sampling=1 polling=1 agent=127.0.0.1 > > dnl sleep long enough to get the sFlow datagram flushed out (may be delayed > for up to 1 second) > AT_CHECK([ovs-appctl time/warp 2000 100], [0], [ignore]) > @@ -6382,7 +6382,7 @@ AT_CHECK([ovs-ofctl add-flow br0 action=3]) > dnl enable sflow > ovs-vsctl \ > set Bridge br0 sflow=@sf -- \ > - --id=@sf create sflow targets=\"127.0.0.1:$SFLOW_PORT\" \ > + --id=@sf create sflow targets=\"127.0.0.1:$SFLOW_PORT\" agent=127.0.0.1 \ > header=128 sampling=1 polling=0 > > dnl introduce a packet that will be flooded to the tunnel > @@ -6474,7 +6474,7 @@ AT_CHECK([ovs-appctl netdev-dummy/receive p0 > 'recirc_id(0),in_port(1),eth(src=f8 > dnl configure sflow on int-br only > ovs-vsctl \ > set Bridge int-br sflow=@sf -- \ > - --id=@sf create sflow targets=\"127.0.0.1:$SFLOW_PORT\" \ > + --id=@sf create sflow targets=\"127.0.0.1:$SFLOW_PORT\" agent=127.0.0.1 \ > header=128 sampling=1 polling=0 > > dnl set up route to 192.168.1.2 via br0 > @@ -6553,7 +6553,7 @@ ovs-appctl time/stop > dnl configure sflow > ovs-vsctl \ > set Bridge br0 sflow=@sf -- \ > - --id=@sf create sflow targets=\"127.0.0.1:$SFLOW_PORT\" \ > + --id=@sf create sflow targets=\"127.0.0.1:$SFLOW_PORT\" agent=127.0.0.1 \ > header=128 sampling=1 polling=0 > > AT_CHECK([ovs-appctl netdev-dummy/receive p1 > 'in_port(1),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x8847),mpls(label=11,tc=3,ttl=64,bos=1)']) > diff --git a/vswitchd/vswitch.xml b/vswitchd/vswitch.xml > index f899a19764a4..9c2a8263e604 100644 > --- a/vswitchd/vswitch.xml > +++ b/vswitchd/vswitch.xml > @@ -5099,13 +5099,24 @@ ovs-vsctl add-port br0 p0 -- set Interface p0 > type=patch options:peer=p1 \ > monitoring of switches.</p> > > <column name="agent"> > - Name of the network device whose IP address should be reported as the > - ``agent address'' to collectors. If not specified, the agent device is > - figured from the first target address and the routing table. If the > - routing table does not contain a route to the target, the IP address > - defaults to the <ref table="Controller" column="local_ip"/> in the > - collector's <ref table="Controller"/>. If an agent IP address cannot > be > - determined any of these ways, sFlow is disabled. > + <p> > + Determines the agent address, that is, the IP address reported to > + collectors as the source of the sFlow data. It may be an IP address > or > + the name of a network device. In the latter case, the network > device's > + IP address is used, > + </p> > + > + <p> > + If not specified, the agent device is figured from the first target > + address and the routing table. If the routing table does not > contain a > + route to the target, the IP address defaults to the <ref > + table="Controller" column="local_ip"/> in the collector's <ref > + table="Controller"/>. > + </p> > + > + <p> > + If an agent IP address cannot be determined, sFlow is disabled. > + </p> > </column> > > <column name="header"> > -- > 2.16.1 > _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
