From patchwork Sun Apr 1 00:12:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 893899 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ovn.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40DG6T69QRz9s3B for ; Sun, 1 Apr 2018 10:13:37 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 4D27CFB4; Sun, 1 Apr 2018 00:13:10 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 565E9F76 for ; Sun, 1 Apr 2018 00:13:08 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 975FA163 for ; Sun, 1 Apr 2018 00:13:03 +0000 (UTC) X-Originating-IP: 173.228.112.105 Received: from sigabrt.gateway.sonic.net (unknown [173.228.112.105]) (Authenticated sender: blp@ovn.org) by relay2-d.mail.gandi.net (Postfix) with ESMTPSA id B379840002; Sun, 1 Apr 2018 02:13:00 +0200 (CEST) From: Ben Pfaff To: dev@openvswitch.org Date: Sat, 31 Mar 2018 17:12:54 -0700 Message-Id: <20180401001255.28283-1-blp@ovn.org> X-Mailer: git-send-email 2.16.1 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Ben Pfaff Subject: [ovs-dev] [PATCH 1/2] vswitchd: Allow user to directly specify sFlow agent address. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org 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 Signed-off-by: Ben Pfaff --- 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.

- 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 in the - collector's . If an agent IP address cannot be - determined any of these ways, sFlow is disabled. +

+ 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, +

+ +

+ 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 in the collector's . +

+ +

+ If an agent IP address cannot be determined, sFlow is disabled. +