PERFORCE change 165594 for review
Ana Kukec
anchie at FreeBSD.org
Sat Jul 4 15:23:26 UTC 2009
http://perforce.freebsd.org/chv.cgi?CH=165594
Change 165594 by anchie at anchie_malimis on 2009/07/04 15:23:00
snd_ifinfo functions; previously that were ng_ifinfo functions.
Affected files ...
.. //depot/projects/soc2009/anchie_send/send_0.2/sendd/net.c#10 edit
.. //depot/projects/soc2009/anchie_send/send_0.2/sendd/os-freebsd/netgraph.c#2 edit
.. //depot/projects/soc2009/anchie_send/send_0.2/sendd/os-freebsd/snd_freebsd.c#3 edit
.. //depot/projects/soc2009/anchie_send/send_0.2/sendd/os-freebsd/snd_freebsd.h#2 edit
.. //depot/projects/soc2009/anchie_send/send_0.2/sendd/os_specific.h#4 edit
.. //depot/projects/soc2009/anchie_send/send_0.2/sendd/sendd.c#7 edit
.. //depot/projects/soc2009/anchie_send/src/sys/netinet6/send.h#12 edit
Differences ...
==== //depot/projects/soc2009/anchie_send/send_0.2/sendd/net.c#10 (text+ko) ====
@@ -74,22 +74,20 @@
return (b);
}
-#if 0
/* Per-interface info */
struct snd_ifinfo {
struct list_head list;
char name[32];
int ifidx;
- int icmps;
-}
+ int snds;
+};
static DEFINE_LIST_HEAD(ifaces);
/* Data packet meta data */
struct input_hook_packet_info {
struct snd_ifinfo *ifinfo;
- int in;
- int from_kernel;
-}
+ int direction;
+};
int
snd_handle_iface(const char *ifname, int ifidx)
@@ -102,9 +100,9 @@
}
memset(p, 0, sizeof (*p));
- snprintf(o->name, sizeof (p->name), "%s", ifname)
+ snprintf(p->name, sizeof (p->name), "%s", ifname);
p->ifidx = ifidx;
- p->icmps = -1;
+ p->snds = -1;
list_add_tail(&p->list, &ifaces);
return (0);
@@ -116,11 +114,24 @@
struct snd_ifinfo *p;
list_for_each_entry(p, &ifaces, list) {
- *maxfd = *maxfd > p->icmps ? *maxfd : p->icmps;
- FD_SET(p->icmps, fds);
+ *maxfd = *maxfd > p->snds ? *maxfd : p->snds;
+ applog(LOG_ERR, "snds added to snd_ifinfo.");
+ FD_SET(p->snds, fds);
}
}
+int
+freebsd_snd_init(void)
+{
+
+ if (list_empty(&ifaces)) {
+ applog(LOG_ERR, "SEND must be active on at least one iface");
+ return (-1);
+ }
+ return (0);
+}
+
+#if 0
void
snd_dispatch_fds(fd_set *fds)
{
@@ -182,7 +193,7 @@
struct rt_msghdr *rtm;
struct if_announcemsghdr *ifan;
struct sbuff *b;
- int in = -1, n, ifidx = -1;
+ int n, ifidx = -1;
if ((b = snd_get_buf()) == NULL) {
return;
@@ -192,6 +203,8 @@
if (n < 0) {
applog(LOG_ERR, "%s: read: %s", __FUNCTION__, strerror(errno));
goto done;
+ } else {
+ applog(LOG_ERR, "%s: %d bytes read on routing socket.", n, __FUNCTION__);
}
b->len = n;
@@ -199,6 +212,8 @@
if (rtm->rtm_version != RTM_VERSION) {
applog(LOG_ERR, "%s: Unsupported routing message version.", __FUNCTION__);
goto done;
+ } else {
+ applog(LOG_ERR, "%s RTM_VERSION", __FUNCTION__);
}
switch (rtm->rtm_type) {
@@ -209,20 +224,16 @@
ifan = (struct if_announcemsghdr *) rtm;
switch (ifan->ifan_what) {
case RTM_SND_IN:
- in = 1;
-
/* n = RTM hdr + m as passed to nd6_ns_input() */
b = (struct rt_msghdr *) &ifan[1];
/* ToDo: Extract ifidx. */
- snd_recv_pkt(b, ifidx, in);
+ snd_recv_pkt(b, ifidx, SND_IN);
break;
case RTM_SND_OUT:
- in = 0;
-
/* n = RTM hdr + ip6_hdr + icmp6len == ND message (as sent to if_output()) */
b = (struct rt_msghdr *) &ifan[1];
/* ToDo: Extract ifidx. */
- snd_recv_pkt(b, ifidx, in);
+ snd_recv_pkt(b, ifidx, SND_OUT);
break;
}
break;
==== //depot/projects/soc2009/anchie_send/send_0.2/sendd/os-freebsd/netgraph.c#2 (text+ko) ====
@@ -357,8 +357,9 @@
DBG(&dbg, "data on unknown hook %s", hook);
goto drop;
}
-
+#if 0
snd_recv_pkt(b, p->ifidx, pi->in, pi);
+#endif
return (0);
drop:
==== //depot/projects/soc2009/anchie_send/send_0.2/sendd/os-freebsd/snd_freebsd.c#3 (text+ko) ====
@@ -34,52 +34,13 @@
#include <list.h>
#include "config.h"
+#include "snd_freebsd.h"
#include "../os_specific.h"
-#include "snd_freebsd.h"
extern int linux_rand_init(void);
extern void linux_rand_fini(void);
-/* Per-interface info */
-struct snd_ifinfo {
- struct list_head list;
- char name[32];
- int ifidx;
- int icmps;
-};
-static DEFINE_LIST_HEAD(ifaces);
-
int
-snd_handle_iface(const char *ifname, int ifidx)
-{
- struct snd_ifinfo *p;
-
- if ((p = malloc(sizeof (*p))) == NULL) {
- APPLOG_NOMEM();
- return (-1);
- }
- memset(p, 0, sizeof (*p));
-
- snprintf(p->name, sizeof (p->name), "%s", ifname);
- p->ifidx = ifidx;
- p->icmps = -1;
- list_add_tail(&p->list, &ifaces);
-
- return (0);
-}
-
-int
-freebsd_snd_init(void)
-{
-
- if (list_empty(&ifaces)) {
- applog(LOG_ERR, "SEND must be active on at least one iface");
- return (-1);
- }
- return (0);
-}
-
-int
os_specific_init(void)
{
if (linux_rand_init() < 0 || freebsd_snd_init() < 0) {
@@ -94,6 +55,8 @@
void
os_specific_fini(void)
{
+#if 0
freebsd_netgraph_fini();
+#endif
linux_rand_fini();
}
==== //depot/projects/soc2009/anchie_send/send_0.2/sendd/os-freebsd/snd_freebsd.h#2 (text+ko) ====
@@ -33,6 +33,8 @@
#ifndef _SND_FREEBSD_H
#define _SND_FREEBSD_H
+extern int freebsd_snd_init(void);
+
extern char *freebsd_get_ifs_buf(int *);
extern int freebsd_ifs_init(int (*cb)(const char *, int));
extern void freebsd_netgraph_fini(void);
==== //depot/projects/soc2009/anchie_send/send_0.2/sendd/os_specific.h#4 (text+ko) ====
==== //depot/projects/soc2009/anchie_send/send_0.2/sendd/sendd.c#7 (text+ko) ====
@@ -47,6 +47,7 @@
#include "sendd_local.h"
#include "snd_config.h"
#include "os_specific.h"
+#include "os/snd_freebsd.h"
#include "dbg.h"
#ifdef DEBUG
@@ -86,6 +87,7 @@
if (cfd != -1) maxfd = cfd;
maxfd = sendd_max(icmps, maxfd);
maxfd = sendd_max(ctlfd, maxfd);
+ maxfd = sendd_max(snds, maxfd);
for (;;) {
FD_ZERO(fds);
@@ -95,7 +97,7 @@
/* Routing socket instead of using netgraph for ND/SeND */
FD_SET(snds, fds);
/* os_specific_add_fds(fds, &maxfd); */
- /* snd_add_fds(fds, &maxfd); */
+ snd_add_fds(fds, &maxfd);
tv = get_next_wait(tvb);
if (select(maxfd + 1, fds, NULL, NULL, tv) < 0) {
==== //depot/projects/soc2009/anchie_send/src/sys/netinet6/send.h#12 (text+ko) ====
@@ -7,8 +7,8 @@
* structure.
*/
-#define SEND_OUT 0 /* outgoing traffic sent to sendd */
-#define SEND_IN 1
+#define SND_OUT 0 /* outgoing traffic sent to sendd */
+#define SND_IN 1
#define RTM_SND_OUT 0 /* outgoing traffic with RTM header sent to sendd */
#define RTM_SND_IN 1 /* incoming traffic with RTM header sent to sendd */
More information about the p4-projects
mailing list