PERFORCE change 165401 for review
Ana Kukec
anchie at FreeBSD.org
Mon Jun 29 14:20:44 UTC 2009
http://perforce.freebsd.org/chv.cgi?CH=165401
Change 165401 by anchie at anchie_malimis on 2009/06/29 14:20:10
Fixes of the code for accepting NS/NA/Redirect on the routing socket.
Affected files ...
.. //depot/projects/soc2009/anchie_send/send_0.2/sendd/net.c#9 edit
.. //depot/projects/soc2009/anchie_send/send_0.2/sendd/sendd.c#5 edit
.. //depot/projects/soc2009/anchie_send/send_0.2/sendd/sendd_local.h#3 edit
Differences ...
==== //depot/projects/soc2009/anchie_send/send_0.2/sendd/net.c#9 (text+ko) ====
@@ -37,6 +37,9 @@
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
+#include <net/route.h>
+#include <net/if.h>
+#include <netinet6/send.h>
#include "config.h"
#include <applog.h>
@@ -71,6 +74,7 @@
return (b);
}
+#if 0
/* Per-interface info */
struct snd_ifinfo {
struct list_head list;
@@ -129,6 +133,7 @@
*/
}
}
+#endif
void
snd_put_buf(struct sbuff *b)
@@ -174,12 +179,10 @@
void
snd_sock_read(void)
{
- char buf[2048];
struct rt_msghdr *rtm;
struct if_announcemsghdr *ifan;
- struct ip6_hdr *ip6;
struct sbuff *b;
- int in = -1;
+ int in = -1, n, ifidx = -1;
if ((b = snd_get_buf()) == NULL) {
return;
@@ -194,14 +197,14 @@
rtm = (struct rt_msghdr *) b;
if (rtm->rtm_version != RTM_VERSION) {
- applog(LOG_ERROR, "%s: Unsupported routing message version.", __FUNCTION__);
+ applog(LOG_ERR, "%s: Unsupported routing message version.", __FUNCTION__);
goto done;
}
switch (rtm->rtm_type) {
case RTM_IFANNOUNCE:
/* XXX: Do we need this? */
- break:
+ break;
case RTM_SND:
ifan = (struct if_announcemsghdr *) rtm;
switch (ifan->ifan_what) {
@@ -209,7 +212,7 @@
in = 1;
/* n = RTM hdr + m as passed to nd6_ns_input() */
- m = (struct rt_msghdr *) &ifan[1];
+ b = (struct rt_msghdr *) &ifan[1];
/* ToDo: Extract ifidx. */
snd_recv_pkt(b, ifidx, in);
break;
@@ -217,14 +220,14 @@
in = 0;
/* n = RTM hdr + ip6_hdr + icmp6len == ND message (as sent to if_output()) */
- m = (struct rt_msghdr *) &ifan[1];
+ b = (struct rt_msghdr *) &ifan[1];
/* ToDo: Extract ifidx. */
snd_recv_pkt(b, ifidx, in);
break;
}
break;
default:
- applog(LOG_ERROR, "%s: Unsupported routing message type.", __FUNTCION__);
+ applog(LOG_ERR, "%s: Unsupported routing message type.", __FUNCTION__);
goto done;
}
@@ -242,7 +245,6 @@
snd_icmp_sock_read(void)
{
struct sockaddr_in6 sin[1];
- struct input_hook_packet_info *pi;
struct sbuff *b;
uint8_t *type;
socklen_t slen;
@@ -271,12 +273,6 @@
goto done;
}
- /* Populate input_hook_packet_info structure! */
- /* 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) {
case ICMP6_SND_CPS:
@@ -298,7 +294,7 @@
snd_put_buf(b);
}
-void
+int
snd_net_init(int *icmp6sock, int *sndsock)
{
int v;
@@ -314,27 +310,29 @@
}
#endif
- if ((icmp6sock = socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6)) < 0) {
+ if ((*icmp6sock = socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6)) < 0) {
applog(LOG_ERR, "%s: socket: %s", __FUNCTION__,
strerror(errno));
return (-1);
}
- if ((sndsock = socket(PF_ROUTE, SOCK_RAW, 0)) < 0) {
+ if ((*sndsock = socket(PF_ROUTE, SOCK_RAW, 0)) < 0) {
applog(LOG_ERR, "%s: socket: %s", __FUNCTION__,
strerror(errno));
return(-1);
+ } else {
+ applog(LOG_ERR, "%s: routing socket created.", __FUNCTION__);
}
v = 255;
- if (setsockopt(icmp6sock, IPPROTO_IPV6, IPV6_UNICAST_HOPS, &v,
+ if (setsockopt(*icmp6sock, IPPROTO_IPV6, IPV6_UNICAST_HOPS, &v,
sizeof (v)) < 0) {
applog(LOG_ERR, "%s: setsockopt(IPV6_UNICAST_HOPS): %s",
__FUNCTION__, strerror(errno));
return (-1);
}
v = 255;
- if (setsockopt(icmp6sock, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, &v,
+ if (setsockopt(*icmp6sock, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, &v,
sizeof (v)) < 0) {
applog(LOG_ERR, "%s: setsockopt(IPV6_MULTICAST_HOPS): %s",
__FUNCTION__, strerror(errno));
@@ -346,11 +344,10 @@
ICMP6_FILTER_SETPASS(ICMP6_SND_CPA, &filter);
ICMP6_FILTER_SETPASS(ND_ROUTER_ADVERT, &filter);
- if (setsockopt(icmp6sock, IPPROTO_ICMPV6, ICMP6_FILTER, &filter,
+ if (setsockopt(*icmp6sock, IPPROTO_ICMPV6, ICMP6_FILTER, &filter,
sizeof (filter)) < 0) {
applog(LOG_ERR, "%s: setsockopt(ICMP6_FILTER): %s",
__FUNCTION__, strerror(errno));
return (-1);
}
-
}
==== //depot/projects/soc2009/anchie_send/send_0.2/sendd/sendd.c#5 (text+ko) ====
@@ -77,7 +77,7 @@
}
static int
-do_select(int icmps, int ctlfd)
+do_select(int icmps, int snds, int ctlfd)
{
fd_set fds[1];
int maxfd = -1;
@@ -116,7 +116,7 @@
#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)) {
@@ -160,7 +160,7 @@
{
const char **lm = applog_get_methods();
- fprintf(stderr, "Usage: %s [-fV] [-c <conf>] [-i <iface>] "
+ fprintf(stderr, "-> Usage: %s [-fV] [-c <conf>] [-i <iface>] "
"[-l <log method>]\n", this);
fprintf(stderr, " log methods: ");
for (; *lm; lm++) {
@@ -239,8 +239,6 @@
exit(1);
}
- snd_net_init(&icmps, &snds);
-
thrpool_init();
if (timer_init() < 0 ||
pkixip_init() < 0 ||
@@ -248,6 +246,7 @@
snd_ssl_init() < 0 ||
snd_cga_init() < 0 ||
snd_params_init() < 0 ||
+ snd_net_init(&icmps, &snds) < 0 ||
icmps < 0 ||
snds < 0 ||
snd_init_cert() < 0 ||
@@ -278,7 +277,7 @@
}
#endif
- r = do_select(icmps, ctlfd);
+ r = do_select(icmps, snds, ctlfd);
snd_cleanup();
exit(r);
==== //depot/projects/soc2009/anchie_send/send_0.2/sendd/sendd_local.h#3 (text+ko) ====
@@ -131,7 +131,7 @@
/* net.c */
extern void snd_icmp_sock_read(void);
extern void snd_sock_read(void);
-extern void snd_net_init(void);
+extern int snd_net_init(int *, int *);
extern struct sbuff *snd_get_buf(void);
extern void snd_put_buf(struct sbuff *);
extern int snd_send_icmp(struct sbuff *, struct sockaddr_in6 *, int);
More information about the p4-projects
mailing list