Some time ago I proposed a diff to allow pflow(4) to determine the src IP address based on the route table if flowsrc was not specified. That diff was not accepted because having multiple places look up route tables is undesirable.
Since then henning@ moved UDP checksum calcs into ip_output. That makes it very simple to allow the pflow flowsrc parameter to be optional. This diff permits the flowsrc parameter to be unspecified, as was permitted prior to version 1.35 of if_flow.c, except that now, thanks to henning@, it works. Nathanael Index: sbin/ifconfig/ifconfig.8 =================================================================== RCS file: /cvs/src/sbin/ifconfig/ifconfig.8,v retrieving revision 1.237 diff -u -p -u -p -r1.237 ifconfig.8 --- sbin/ifconfig/ifconfig.8 13 Oct 2013 10:45:34 -0000 1.237 +++ sbin/ifconfig/ifconfig.8 15 Jan 2014 18:20:18 -0000 @@ -1224,12 +1224,11 @@ Pflow data will be sent to this address/ Unset the receiver address and stop sending pflow data. .It Cm flowsrc Ar addr Set the source IP address for pflow packets. -Must be defined to export pflow data. .Ar addr is the IP address used as sender of the UDP packets and may be used to identify the source of the data on the pflow collector. .It Fl flowsrc -Unset the source address and stop sending pflow data. +Unset the source address. .It Cm pflowproto Ar n Set the protocol version. The default is version 5. Index: sbin/ifconfig/ifconfig.c =================================================================== RCS file: /cvs/src/sbin/ifconfig/ifconfig.c,v retrieving revision 1.280 diff -u -p -u -p -r1.280 ifconfig.c --- sbin/ifconfig/ifconfig.c 1 Dec 2013 10:05:29 -0000 1.280 +++ sbin/ifconfig/ifconfig.c 15 Jan 2014 18:20:18 -0000 @@ -3879,8 +3879,9 @@ pflow_status(void) if (ioctl(s, SIOCGETPFLOW, (caddr_t)&ifr) == -1) return; - printf("\tpflow: sender: %s ", preq.sender_ip.s_addr != INADDR_ANY ? - inet_ntoa(preq.sender_ip) : "INVALID"); + printf("\tpflow: "); + if (preq.sender_ip.s_addr != INADDR_ANY) + printf("sender: %s ", inet_ntoa(preq.sender_ip)); printf("receiver: %s:", preq.receiver_ip.s_addr != INADDR_ANY ? inet_ntoa(preq.receiver_ip) : "INVALID"); if (preq.receiver_port == 0) Index: share/man/man4/pflow.4 =================================================================== RCS file: /cvs/src/share/man/man4/pflow.4,v retrieving revision 1.16 diff -u -p -u -p -r1.16 pflow.4 --- share/man/man4/pflow.4 14 Sep 2013 14:54:30 -0000 1.16 +++ share/man/man4/pflow.4 15 Jan 2014 18:20:18 -0000 @@ -42,8 +42,7 @@ Multiple interfaces can be created at runtime using the .Ic ifconfig pflow Ns Ar N Ic create command. -Each interface must be configured with a flow sender IP address, -a flow receiver IP address, +Each interface must be configured with a flow receiver IP address and a flow receiver port number. .Pp Only states created by a rule marked with the @@ -92,8 +91,6 @@ collector. .Cm flowdst defines the collector IP address and the port. The -.Cm flowsrc -IP address and .Cm flowdst IP address and port must be defined to enable the export of flows. .Pp Index: sys/net/if_pflow.c =================================================================== RCS file: /cvs/src/sys/net/if_pflow.c,v retrieving revision 1.38 diff -u -p -u -p -r1.38 if_pflow.c --- sys/net/if_pflow.c 1 Nov 2013 14:34:27 -0000 1.38 +++ sys/net/if_pflow.c 15 Jan 2014 18:20:23 -0000 @@ -426,7 +426,6 @@ pflowioctl(struct ifnet *ifp, u_long cmd if ((ifp->if_flags & IFF_UP) && sc->sc_receiver_ip.s_addr != INADDR_ANY && sc->sc_receiver_port != 0 && - sc->sc_sender_ip.s_addr != INADDR_ANY && sc->sc_sender_port != 0) { ifp->if_flags |= IFF_RUNNING; sc->sc_gcounter=pflowstats.pflow_flows; @@ -506,7 +505,6 @@ pflowioctl(struct ifnet *ifp, u_long cmd if ((ifp->if_flags & IFF_UP) && sc->sc_receiver_ip.s_addr != INADDR_ANY && sc->sc_receiver_port != 0 && - sc->sc_sender_ip.s_addr != INADDR_ANY && sc->sc_sender_port != 0) { ifp->if_flags |= IFF_RUNNING; sc->sc_gcounter=pflowstats.pflow_flows;