PERFORCE change 164312 for review
Ana Kukec
anchie at FreeBSD.org
Sun Jun 14 00:28:33 UTC 2009
http://perforce.freebsd.org/chv.cgi?CH=164312
Change 164312 by anchie at anchie_malimis on 2009/06/14 00:27:44
Changing send-0.2 to support receiving of the incoming NS/A, RS/A and
Redirect routing socket messages through the output hook
(netinet6/send.c)
Affected files ...
.. //depot/projects/soc2009/anchie_send/send_0.2/sendd/net.c#6 edit
.. //depot/projects/soc2009/anchie_send/send_0.2/sendd/os_specific.h#3 edit
.. //depot/projects/soc2009/anchie_send/send_0.2/sendd/proto.c#4 edit
.. //depot/projects/soc2009/anchie_send/send_0.2/sendd/sendd.c#4 edit
Differences ...
==== //depot/projects/soc2009/anchie_send/send_0.2/sendd/net.c#6 (text+ko) ====
@@ -47,7 +47,8 @@
#include "snd_proto.h"
#include "dbg.h"
-static int icmp6sock = -1;
+static int icmp6sock = -1;
+static int sndsock = -1;
#ifdef DEBUG
static struct dlog_desc dbg = {
@@ -173,57 +174,52 @@
void
snd_sock_read(void)
{
- struct sockaddr_in6 sin[1];
- struct sbuff *b;
- uint8_t *type;
- socklen_t slen;
-
- if (b = snd_get_buf()) == NULL) {
- return;
+ char buf[2048];
+ struct rt_msghdr *rtm;
+ struct if_announcemsghdr *ifan;
+ struct ip6_hdr *ip6;
+ struct mbuf *m;
+ int in = -1;
+
+ n = read(sndsock, buf, sizeof(buf));
+ if (n < 0) {
+ applog(LOG_ERR, "%s: read: %s", __FUNCTION__, strerror(errno));
+ goto done;
}
- slen = sizeof(*sin);
- if ((r = recvfrom(snds, b->hread, b->rem, 0, (void *)sin, &slen))
- < 0) {
- applog(LOG_ERR, "%s: recvfrom: %s", __FUNCTION__,
- strerror(errno));
+ rtm = (struct rt_msghdr *) buf;
+ if (rtm->rtm_version != RTM_VERSION) {
+ applog(LOG_ERROR, "%s: Unsupported routing message version.", __FUNCTION__);
goto done;
}
- b->len = r;
- DBG(&dbg, "%d bytes from %s on IF %d", r,
- inet_ntop(AF_INET6, &sin->sin6_addr, abuf, sizeof (abuf)),
- sin->sin6_scope_id);
+ switch (rtm->rtm_type) {
+ case RTM_IFANNOUNCE:
+ /* XXX: Do we need this? */
+ break:
+ case RTM_SND:
+ ifan = (struct if_announcemsghdr *) rtm;
+ switch (ifan->ifan_what) {
+ case RTM_SND_IN:
+ in = 1;
- if (IN6_IS_ADDR_LOOPBACK(&sin->sin6_addr)) {
- DBG(&dbg, "Dropping request from loopback");
- goto done;
+ /* n = RTM hdr + m as passed to nd6_ns_input() */
+ m = (struct ip6_hdr *) &ifan[1];
- /* Further processing should be done according to snd_recv_pkt(). */
- type = sbuff_data(b);
- switch (*type) {
- case ND_NEIGHBOR_SOLICIT:
- snd_handle_ns(b, sin, sin->sin6_scope_id);
- break;
- case ND_NEIGHBOR_ADVERT:
- snd_handle_na(b, sin);
- break;
- case ND_ROUTER_SOLICIT:
- snd_handle_rs(b, sin, sin->sin6_scope_id);
- break;
- case ND_ROUTER_ADVERT:
- snd_process_ra(sbuff_data(b), r, sin->sin6_scope_id,
- &sin->sin6_addr);
- break;
- case ND_REDIRECT:
+ /* ToDo: Extract ifidx. */
+ snd_recv_pkt(m, ifidx, in);
+ break;
+ case RTM_SND_OUT:
+ break;
+ }
break;
default:
- DBG(&dbg_snd, "Unhandled ICMP6 type %d", *type);
- break;
+ applog(LOG_ERROR, "%s: Unsupported routing message type.", __FUNTCION__);
+ goto done;
}
done:
- snd_put_buf(b);
+ /* ToDo: Free memory! */
}
/*
@@ -296,7 +292,6 @@
{
int v;
struct icmp6_filter filter;
- struct icmp6_filter snd_filter;
#ifdef DEBUG
struct dlog_desc *dbgs[] = {
&dbg,
@@ -340,12 +335,6 @@
ICMP6_FILTER_SETPASS(ICMP6_SND_CPA, &filter);
ICMP6_FILTER_SETPASS(ND_ROUTER_ADVERT, &filter);
- ICMP6_FILTER_SETBLOCKALL(&snd_filter);
- ICMP6_FILTER_SETPASS(ND_ROUTER_SOLICIT, &snd_filter);
- ICMP6_FILTER_SETPASS(ND_ROUTER_ADVERT, &snd_filter);
- ICMP6_FILTER_SETPASS(ND_NEIGHBOR_SOLICIT, &snd_filter);
- ICMP6_FILTER_SETPASS(ND_NEIGHBOR_ADVERT, &snd_filter);
-
if (setsockopt(icmp6sock, IPPROTO_ICMPV6, ICMP6_FILTER, &filter,
sizeof (filter)) < 0) {
applog(LOG_ERR, "%s: setsockopt(ICMP6_FILTER): %s",
@@ -353,10 +342,4 @@
return (-1);
}
- if (setsockopt(sndsock, IPPROTO_ICMPV6, ICMP6_FILTER, &snd_filter,
- sizeof (snd_filter)) < 0) {
- applog(LOG_ERR, "%s: setsockopt(ICMP6_FILTER): %s",
- __FUNCTION__, strerror(errno));
- return (-1);
- }
}
==== //depot/projects/soc2009/anchie_send/send_0.2/sendd/os_specific.h#3 (text+ko) ====
@@ -36,7 +36,8 @@
#include <netinet/in.h>
#include <sbuff.h>
-extern void snd_recv_pkt(struct sbuff *, int, int, void *);
+/* extern void snd_recv_pkt(struct sbuff *, int, int, void *); */
+extern void snd_recv_pkt(struct sbuff *, int, int);
extern int os_specific_add_addr(struct in6_addr *, int, int, uint32_t,
uint32_t);
==== //depot/projects/soc2009/anchie_send/send_0.2/sendd/proto.c#4 (text+ko) ====
@@ -654,7 +654,8 @@
}
void
-snd_recv_pkt(struct sbuff *b, int ifidx, int in, void *pkt)
+/* snd_recv_pkt(struct sbuff *b, int ifidx, int in, void *pkt) */
+snd_recv_pkt(struct sbuff *b, int ifidx, int in)
{
int tlen, drop = 0;
int changed = 0;
@@ -663,10 +664,11 @@
enum snd_pkt_decision r;
void *start;
struct ip6_hdr *iph;
-
+/*
if (!snd_iface_ok_(ifidx)) {
return;
}
+*/
start = sbuff_data(b);
DBG(&dbg, "%s", in ? "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" :
@@ -678,7 +680,7 @@
}
memset(pi, 0, sizeof (*pi));
pi->b = b;
- pi->os_pkt = pkt;
+ /* XXX: We don't need this anymore!! -> pi->os_pkt = pkt; */
pi->ifidx = ifidx;
/* Save packet start and len */
@@ -766,7 +768,10 @@
drop = 1;
done:
b->data = start;
- /* ToDo: The packet is here sent through netgraph. Change this! */
+ /*
+ * ToDo: The packet is here sent through netgraph. Will be sent back
+ * to kernel through the input hook.
+ */
/* os_specific_deliver_pkt(pkt, b, drop, changed); */
}
==== //depot/projects/soc2009/anchie_send/send_0.2/sendd/sendd.c#4 (text+ko) ====
@@ -125,7 +125,6 @@
if (FD_ISSET(snds, fds)) {
snd_sock_read();
}
- /* snd_dispatch_fds(fds); */
/* os_specific_dispatch_fds(fds); */
snd_replace_non_cga_linklocals();
}
More information about the p4-projects
mailing list