PERFORCE change 163913 for review
Ana Kukec
anchie at FreeBSD.org
Tue Jun 9 16:57:54 UTC 2009
http://perforce.freebsd.org/chv.cgi?CH=163913
Change 163913 by anchie at anchie_malimis on 2009/06/09 16:56:51
Initial code for per-interface processing of SEND messages, that used
to be received through netgraph.
Affected files ...
.. //depot/projects/soc2009/anchie_send/send_0.2/sendd/addr.c#2 edit
.. //depot/projects/soc2009/anchie_send/send_0.2/sendd/net.c#3 edit
.. //depot/projects/soc2009/anchie_send/send_0.2/sendd/proto.c#2 edit
.. //depot/projects/soc2009/anchie_send/send_0.2/sendd/sendd.c#2 edit
Differences ...
==== //depot/projects/soc2009/anchie_send/send_0.2/sendd/addr.c#2 (text+ko) ====
@@ -281,9 +281,14 @@
return (0);
}
+ /*
if (os_specific_handle_iface(entry->intf_name, ifidx) < 0) {
return (-1);
}
+ */
+ if (snd_handle_iface(entry->intf_name, ifidx) < 0) {
+ return (-1);
+ }
intf_cfg_addr(&entry->intf_addr, ifidx);
==== //depot/projects/soc2009/anchie_send/send_0.2/sendd/net.c#3 (text+ko) ====
@@ -69,6 +69,64 @@
return (b);
}
+/* Per-interface info */
+struct snd_ifinfo {
+ struct list_head list;
+ char name[32];
+ int ifidx;
+ int icmps;
+}
+static DEFINE_LIST_HEAD(ifaces);
+
+/* Data packet meta data */
+struct input_hook_packet_info {
+ struct snd_ifinfo *ifinfo;
+ int in;
+ int from_kernel;
+}
+
+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(o->name, sizeof (p->name), "%s", ifname)
+ p->ifidx = ifidx;
+ p->icmps = -1;
+ list_add_tail(&p->list, &ifaces);
+
+ return (0);
+}
+
+void
+snd_add_fds(fd_set *fds, int *maxfd)
+{
+ struct snd_ifinfo *p;
+
+ list_for_each_entry(p, &ifaces, list) {
+ *maxfd = *maxfd > p->icmps ? *maxfd : p->icmps;
+ FD_SET(p->icmps, fds);
+ }
+}
+
+void
+snd_dispatch_fds(fd_set *fds)
+{
+ struct snd_ifinfo *p;
+
+ list_for_each_entry(p, &ifaces, list) {
+ if (FD_ISSET(p->icmps, fds)) {
+ /* Reuse the code from
+ snd_recv_pkt() and snd_icmp_sock_read()
+ */
+ }
+
void
snd_put_buf(struct sbuff *b)
{
@@ -119,7 +177,7 @@
snd_icmp_sock_read(void)
{
struct sockaddr_in6 sin[1];
- struct input_hook_packet_info pi;
+ struct input_hook_packet_info *pi;
struct sbuff *b;
uint8_t *type;
socklen_t slen;
@@ -149,7 +207,10 @@
}
/* Populate input_hook_packet_info structure! */
- /* Populate ifidx and in integers. */
+ /* Determine if the packet was sent to sendd by kernel or other sendd. */
+ pi->from_kernel = 1;
+
+ pi->in = 1;
type = sbuff_data(b);
switch (*type) {
@@ -164,8 +225,7 @@
&sin->sin6_addr);
break;
default:
- snd_recv_pkt(sbuff_data(b), ifidx, in, pi);
-
+ DBG(&dbg_snd, "Unhandled ICMP6 type %d", *type);
break;
}
==== //depot/projects/soc2009/anchie_send/send_0.2/sendd/proto.c#2 (text+ko) ====
@@ -664,9 +664,6 @@
void *start;
struct ip6_hdr *iph;
- if (!snd_iface_ok(ifidx)) {
- return;
- }
start = sbuff_data(b);
DBG(&dbg, "%s", in ? "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" :
@@ -719,11 +716,13 @@
}
if (in) {
+ /*
if (snd_is_lcl_cga(pi->cga, ifidx)) {
DBG(&dbg, "is local; don't need to check");
drop = 0;
goto done;
}
+ */
if (snd_parse_opts(&pi->ndopts, sbuff_data(b), b->len) < 0) {
goto drop;
}
@@ -733,7 +732,7 @@
/* skip all options */
sbuff_advance(b, b->len);
b->len = tlen;
-
+ /*
if (!snd_is_lcl_cga(pi->cga, ifidx)) {
DBG(&dbg_snd, "outgoing: not CGA, dropping");
if (dad && IN6_IS_ADDR_LINKLOCAL(pi->cga)) {
@@ -742,6 +741,7 @@
}
goto drop;
}
+ */
r = handle_outgoing(pi);
}
@@ -763,7 +763,8 @@
drop = 1;
done:
b->data = start;
- os_specific_deliver_pkt(pkt, b, drop, changed);
+ /* ToDo: The packet is here sent through netgraph. Change this! */
+ /* os_specific_deliver_pkt(pkt, b, drop, changed); */
}
int
==== //depot/projects/soc2009/anchie_send/send_0.2/sendd/sendd.c#2 (text+ko) ====
@@ -92,7 +92,8 @@
if (cfd != -1) FD_SET(cfd, fds);
FD_SET(icmps, fds);
FD_SET(ctlfd, fds);
- os_specific_add_fds(fds, &maxfd);
+ /* os_specific_add_fds(fds, &maxfd); */
+ snd_add_fds(fds, &maxfd);
tv = get_next_wait(tvb);
if (select(maxfd + 1, fds, NULL, NULL, tv) < 0) {
@@ -113,13 +114,14 @@
#endif /* USE_READLINE */
}
#endif /* USE_CONSOLE */
- if (FD_ISSET(icmps, fds)) {
+ if (FD_ISSET(icmps, fds) {
snd_icmp_sock_read();
}
if (FD_ISSET(ctlfd, fds)) {
snd_ctl_read(ctlfd);
}
- os_specific_dispatch_fds(fds);
+ snd_dispatch_fds(fds);
+ /* os_specific_dispatch_fds(fds); */
snd_replace_non_cga_linklocals();
}
}
More information about the p4-projects
mailing list