Sorry, here is the patch that was to supposed to be attached to the previous message.
Best regards, Giuseppe Lettieri Il 28/06/2012 11:10, Giuseppe Lettieri ha scritto: > Hi, > > we are working on a port of Open vSwitch to FreeBSD. This patch is a > first step toward that direction. It only allows clean compilation of > the git master branch with default configuration. It protects the > changes that were introduced in commit 733adf2a, so that they are only > enabled on Linux with netlink. If you are interested, we would like to > also share the more substantial patches when we have finished testing them. > > Best regards, > Giuseppe Lettieri > -- Dr. Ing. Giuseppe Lettieri Dipartimento di Ingegneria della Informazione Universita' di Pisa Largo Lucio Lazzarino 2, 56122 Pisa - Italy Ph. : (+39) 050-2217.649 (direct) .599 (switch) Fax : (+39) 050-2217.600 e-mail: g.letti...@iet.unipi.it
>From 217e648afe58863ef0cb78799176c9a25c8a779f Mon Sep 17 00:00:00 2001 From: Giuseppe Lettieri <g.letti...@iet.unipi.it> Date: Fri, 11 May 2012 14:11:00 +0200 Subject: [PATCH] fix compilation on FreeBSD Signed-off-by: Giuseppe Lettieri <g.letti...@iet.unipi.it> --- lib/vlandev.c | 2 +- ofproto/ofproto-dpif-sflow.c | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletions(-) diff --git a/lib/vlandev.c b/lib/vlandev.c index 77e8e93..ffb8e73 100644 --- a/lib/vlandev.c +++ b/lib/vlandev.c @@ -23,13 +23,13 @@ #include <sys/stat.h> #include "hash.h" -#include "rtnetlink-link.h" #include "shash.h" #include "vlog.h" VLOG_DEFINE_THIS_MODULE(vlandev); #ifdef __linux__ +#include "rtnetlink-link.h" #include <linux/if_vlan.h> #include <linux/sockios.h> #include "netdev-linux.h" diff --git a/ofproto/ofproto-dpif-sflow.c b/ofproto/ofproto-dpif-sflow.c index 611f89a..e68b94b 100644 --- a/ofproto/ofproto-dpif-sflow.c +++ b/ofproto/ofproto-dpif-sflow.c @@ -18,7 +18,9 @@ #include <config.h> #include "ofproto-dpif-sflow.h" #include <inttypes.h> +#ifdef HAVE_NETLINK #include <net/if.h> +#endif /* HAVE_NETLINK */ #include <stdlib.h> #include "collectors.h" #include "compiler.h" @@ -31,7 +33,9 @@ #include "ofproto.h" #include "packets.h" #include "poll-loop.h" +#ifdef HAVE_NETLINK #include "route-table.h" +#endif /* HAVE_NETLINK */ #include "sflow_api.h" #include "socket-util.h" #include "timeval.h" @@ -229,18 +233,35 @@ sflow_agent_get_counters(void *ds_, SFLPoller *poller, * specified then it is figured out by taking a look at the routing table based * on 'targets'. */ static bool +#ifndef HAVE_NETLINK +sflow_choose_agent_address(const char *agent_device, const char *control_ip, + SFLAddress *agent_addr) +#else sflow_choose_agent_address(const char *agent_device, const struct sset *targets, const char *control_ip, SFLAddress *agent_addr) +#endif /* HAVE_NETLINK */ { +#ifdef HAVE_NETLINK const char *target; +#endif /* HAVE_NETLINK */ struct in_addr in4; memset(agent_addr, 0, sizeof *agent_addr); agent_addr->type = SFLADDRESSTYPE_IP_V4; if (agent_device) { +#ifndef HAVE_NETLINK + struct netdev *netdev; + + if (!netdev_open(agent_device, "system", &netdev)) { + int error = netdev_get_in4(netdev, &in4, NULL); + netdev_close(netdev); + if (!error) { + goto success; + } +#else if (!netdev_get_in4_by_name(agent_device, &in4)) { goto success; } @@ -254,6 +275,7 @@ sflow_choose_agent_address(const char *agent_device, && route_table_get_name(sin.sin_addr.s_addr, name) && !netdev_get_in4_by_name(name, &in4)) { goto success; +#endif /* HAVE_NETLINK */ } } @@ -301,8 +323,10 @@ dpif_sflow_create(struct dpif *dpif) ds->next_tick = time_now() + 1; hmap_init(&ds->ports); ds->probability = 0; +#ifdef HAVE_NETLINK route_table_register(); +#endif /* HAVE_NETLINK */ return ds; } @@ -321,7 +345,9 @@ dpif_sflow_destroy(struct dpif_sflow *ds) if (ds) { struct dpif_sflow_port *dsp, *next; +#ifdef HAVE_NETLINK route_table_unregister(); +#endif /* HAVE_NETLINK */ dpif_sflow_clear(ds); HMAP_FOR_EACH_SAFE (dsp, next, hmap_node, &ds->ports) { dpif_sflow_del_port__(ds, dsp); @@ -433,6 +459,7 @@ dpif_sflow_set_options(struct dpif_sflow *ds, } } +#ifdef HAVE_NETLINK /* Choose agent IP address and agent device (if not yet setup) */ if (!sflow_choose_agent_address(options->agent_device, &options->targets, @@ -441,6 +468,7 @@ dpif_sflow_set_options(struct dpif_sflow *ds, return; } +#endif /* HAVE_NETLINK */ /* Avoid reconfiguring if options didn't change. */ if (!options_changed) { return; @@ -448,6 +476,15 @@ dpif_sflow_set_options(struct dpif_sflow *ds, ofproto_sflow_options_destroy(ds->options); ds->options = ofproto_sflow_options_clone(options); +#ifndef HAVE_NETLINK + /* Choose agent IP address. */ + if (!sflow_choose_agent_address(options->agent_device, + options->control_ip, &agentIP)) { + dpif_sflow_clear(ds); + return; + } + +#endif /* HAVE_NETLINK */ /* Create agent. */ VLOG_INFO("creating sFlow agent %d", options->sub_id); if (ds->sflow_agent) { @@ -567,7 +604,9 @@ dpif_sflow_run(struct dpif_sflow *ds) { if (dpif_sflow_is_enabled(ds)) { time_t now = time_now(); +#ifdef HAVE_NETLINK route_table_run(); +#endif /* HAVE_NETLINK */ if (now >= ds->next_tick) { sfl_agent_tick(ds->sflow_agent, time_wall()); ds->next_tick = now + 1; -- 1.7.3.4
_______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev