[Asterisk-bsd] Re: One Way Audio

Tom Ivar Helbekkmo tih at eunetnorge.no
Mon Oct 18 02:29:09 CDT 2004


Tom Ivar Helbekkmo <tih at eunetnorge.no> writes:

> However, I've gotten a bit further by now: it seems that the problem
> is actually a bug in the NetBSD routing socket handling, and the patch
> I supplied earlier actually just got rid of the visible symptom.  I'll
> be digging deeper, and will supply a proper fix later, but for now you
> should try the above mentioned workaround.

Such was, indeed, the case.  :-(

I've submitted a new patch to Digium to reinstate the proper use of
the routing socket, and will be submitting a patch to the NetBSD
maintainers to make this feature actually work there.  Meanwhile, what
you want is for the relevant bit of Asterisk's acl.c to look like this:

	memset(&m_rtmsg, 0, sizeof(m_rtmsg));
	m_rtmsg.m_rtm.rtm_type = RTM_GET;
	m_rtmsg.m_rtm.rtm_version = RTM_VERSION;
	ast_mutex_lock(&routeseq_lock);
	seq = ++routeseq;
	ast_mutex_unlock(&routeseq_lock);
	m_rtmsg.m_rtm.rtm_seq = seq;
	m_rtmsg.m_rtm.rtm_addrs = RTA_DST | RTA_IFA;
	m_rtmsg.m_rtm.rtm_msglen = sizeof(struct rt_msghdr) + sizeof(struct sockaddr_in);
	sin = (struct sockaddr_in *)m_rtmsg.m_space;
	sin->sin_family = AF_INET;
	sin->sin_len = sizeof(struct sockaddr_in);
	sin->sin_addr = *them;

Specifically, "| RTA_IFA" needs to be added to the line setting the
value of rtm_addrs.  This flag in that field has a special, overloaded
meaning when rtm_type is RTM_GET, which is seldom used, and, in fact,
doesn't work in NetBSD due to overzealous sanity checking of the
parameters.  (Yes, this usage is a kludge in the routing socket.)

If you want "bindaddr = 0.0.0.0" to work, you have to change acl.c
back to the above (the attached patch DIFFS.acl.txt will do it, from
the current CVS), and apply the attached patch DIFFS.rtsock.txt to
your NetBSD kernel source.  NOTE: this is NOT a sanctioned patch to
NetBSD; it is what I think is the right thing to do.  It may or may
not be acceptable to the NetBSD maintainers.  Your mileage may vary.

-------------- next part --------------
Index: acl.c
===================================================================
RCS file: /usr/cvsroot/asterisk/acl.c,v
retrieving revision 1.28
diff -u -r1.28 acl.c
--- acl.c	14 Oct 2004 18:48:04 -0000	1.28
+++ acl.c	18 Oct 2004 06:53:04 -0000
@@ -242,13 +242,12 @@
 
 	memset(&m_rtmsg, 0, sizeof(m_rtmsg));
 	m_rtmsg.m_rtm.rtm_type = RTM_GET;
-	m_rtmsg.m_rtm.rtm_flags = RTF_UP | RTF_HOST;
 	m_rtmsg.m_rtm.rtm_version = RTM_VERSION;
 	ast_mutex_lock(&routeseq_lock);
 	seq = ++routeseq;
 	ast_mutex_unlock(&routeseq_lock);
 	m_rtmsg.m_rtm.rtm_seq = seq;
-	m_rtmsg.m_rtm.rtm_addrs = RTA_DST;
+	m_rtmsg.m_rtm.rtm_addrs = RTA_DST | RTA_IFA;
 	m_rtmsg.m_rtm.rtm_msglen = sizeof(struct rt_msghdr) + sizeof(struct sockaddr_in);
 	sin = (struct sockaddr_in *)m_rtmsg.m_space;
 	sin->sin_family = AF_INET;
-------------- next part --------------
Index: sys/net/rtsock.c
===================================================================
RCS file: /cvsroot/src/sys/net/rtsock.c,v
retrieving revision 1.71
diff -u -r1.71 rtsock.c
--- sys/net/rtsock.c	25 May 2004 04:33:59 -0000	1.71
+++ sys/net/rtsock.c	18 Oct 2004 06:47:17 -0000
@@ -100,7 +100,7 @@
 
 static struct mbuf *rt_msg1(int, struct rt_addrinfo *, caddr_t, int);
 static int rt_msg2(int, struct rt_addrinfo *, caddr_t, struct walkarg *, int *);
-static int rt_xaddrs(const char *, const char *, struct rt_addrinfo *);
+static int rt_xaddrs(u_char, const char *, const char *, struct rt_addrinfo *);
 static int sysctl_dumpentry(struct radix_node *, void *);
 static int sysctl_iflist(int, struct walkarg *, int);
 static int sysctl_rtable(SYSCTLFN_PROTO);
@@ -235,7 +235,7 @@
 	rtm->rtm_pid = curproc->p_pid;
 	memset(&info, 0, sizeof(info));
 	info.rti_addrs = rtm->rtm_addrs;
-	if (rt_xaddrs((caddr_t)(rtm + 1), len + (caddr_t)rtm, &info))
+	if (rt_xaddrs(rtm->rtm_type, (caddr_t)(rtm + 1), len + (caddr_t)rtm, &info))
 		senderr(EINVAL);
 	info.rti_flags = rtm->rtm_flags;
 	if (dst == 0 || (dst->sa_family >= AF_MAX))
@@ -470,7 +470,7 @@
 #define ADVANCE(x, n) (x += ROUNDUP((n)->sa_len))
 
 static int
-rt_xaddrs(const char *cp, const char *cplim, struct rt_addrinfo *rtinfo)
+rt_xaddrs(u_char rtmtype, const char *cp, const char *cplim, struct rt_addrinfo *rtinfo)
 {
 	const struct sockaddr *sa = NULL;	/* Quell compiler warning */
 	int i;
@@ -482,9 +482,14 @@
 		ADVANCE(cp, sa);
 	}
 
-	/* Check for extra addresses specified.  */
-	if ((rtinfo->rti_addrs & (~0 << i)) != 0)
-		return (1);
+	/* Check for extra addresses specified, except RTM_GET asking for interface info.  */
+	if (rtmtype == RTM_GET) {
+		if (((rtinfo->rti_addrs & (~((1 << RTAX_IFP) | (1 << RTAX_IFA)))) & (~0 << i)) != 0)
+			return (1);
+	} else {
+		if ((rtinfo->rti_addrs & (~0 << i)) != 0)
+			return (1);
+	}
 	/* Check for bad data length.  */
 	if (cp != cplim) {
 		if (i == RTAX_NETMASK + 1 &&
-------------- next part --------------

-tih
-- 
Tom Ivar Helbekkmo, Senior System Administrator, EUnet Norway Hosting
www.eunet.no  T +47-22092958 M +47-93013940 F +47-22092901 FWD 484145


More information about the Asterisk-BSD mailing list