Re: Merge uhts(4) into ums(4).

2013-08-09 Thread Matthieu Herrb
On Wed, Aug 07, 2013 at 09:20:21AM +0100, Edd Barrett wrote:
 On Fri, Jul 19, 2013 at 04:06:49PM +0100, Edd Barrett wrote:
  Cheers. Revised diff:
 
 Right, now the tree is open again.
 
 Matthieu, did you test this diff on your various devices for
 regressions? Can this go in?
 

Sorry for the delays. Yes now all my devices attach to ums. This can
go in. And you can also do the next step and tedu uhts 
-- 
Matthieu Herrb



Re: nd6 expire

2013-08-09 Thread Martin Pieuchot
On 08/08/13(Thu) 21:34, Alexander Bluhm wrote:
 On Thu, Aug 08, 2013 at 01:47:17PM +0200, Martin Pieuchot wrote:
  On 08/08/13(Thu) 01:06, Alexander Bluhm wrote:
   Hi,
   
   To control the lifetime of IPv6 addresses, prefixes and default
   routers, the kernel and ndp use a bunch of expire fields.  Currently
   they are int or long, but expire should always be time_t.  Move
   vltime and pltime to u_int32_t everywhere.  Sort struct fields by
   size.  Struct inet6_ndpr_msghdr is not used at all, so remove it.
  
  It looks to me that the in6_oprlist structure is here only for some 
  binary compatibility.  So changing its fields makes no sense, however
  I think you can completely remove it as it has been introduced in
  2002 and nothing use the SIOCGPRLST_IN6 ioctl(2) anymore. ;)
 
 We have the code
 oprl-prefix[i].expire = pr-ndpr_expire;
 in the kernel right now.  It is wrong to leave in6_oprlist.prefix-expire
 as u_long and ndpr_expire as time_t.
 
 Binary compatibility for ndp will break with this diff anyway and
 for most programs with the big time_t diff.
 
 Ndp implements ioctl(s, SIOCGPRLST_IN6, (caddr_t)pr), but does not
 use it because of #ifdef.
 
 I would like to do it this way:
 1. fix time_t in all structures with this diff
 2. throw away #ifdef in ndp
 3. remove obsolete ioctl from kernel
 4. remove obsolete struct from header
 
 ok?

I think it's safer to do 1. after the three other steps, but I don't
really have a strong opinion.  You have my ok for this diff but you
might also consider folding this change into the big time_t diff.

Alternatively you can also split this diff into the kernel-only part
(changing the nd_defrouter and nd_prefix structure) and the part also
used by userland applications.

Martin



Stop using static variables in ICMP

2013-08-09 Thread Martin Pieuchot
This is the last episode from the first season of the serie, move
your variables to the stack.  Like in the previous episodes, this
one will let us execute the various icmp functions in parallel
without risk of trashing a value.

It also reduces the difference with the icmp6 code adding a redirect
route.

ok?

Index: netinet/ip_icmp.c
===
RCS file: /home/ncvs/src/sys/netinet/ip_icmp.c,v
retrieving revision 1.104
diff -u -p -r1.104 ip_icmp.c
--- netinet/ip_icmp.c   8 Aug 2013 14:59:22 -   1.104
+++ netinet/ip_icmp.c   9 Aug 2013 08:40:27 -
@@ -297,10 +297,6 @@ icmp_error(struct mbuf *n, int type, int
icmp_send(m, NULL);
 }
 
-struct sockaddr_in icmpsrc = { sizeof (struct sockaddr_in), AF_INET };
-static struct sockaddr_in icmpdst = { sizeof (struct sockaddr_in), AF_INET };
-static struct sockaddr_in icmpgw = { sizeof (struct sockaddr_in), AF_INET };
-
 /*
  * Process a received ICMP message.
  */
@@ -309,14 +305,11 @@ icmp_input(struct mbuf *m, ...)
 {
struct icmp *icp;
struct ip *ip = mtod(m, struct ip *);
-   int icmplen;
-   int i;
+   struct sockaddr_in sin;
+   int icmplen, i, code, hlen;
struct in_ifaddr *ia;
void *(*ctlfunc)(int, struct sockaddr *, u_int, void *);
-   int code;
-   int hlen;
va_list ap;
-   struct rtentry *rt;
struct mbuf *opts;
 
va_start(ap, m);
@@ -479,10 +472,13 @@ icmp_input(struct mbuf *m, ...)
if (icmpprintfs)
printf(deliver to protocol %d\n, icp-icmp_ip.ip_p);
 #endif
-   icmpsrc.sin_addr = icp-icmp_ip.ip_dst;
+   bzero(sin, sizeof(sin));
+   sin.sin_family = AF_INET;
+   sin.sin_len = sizeof(struct sockaddr_in);
+   sin.sin_addr = icp-icmp_ip.ip_dst;
 #if NCARP  0
if (m-m_pkthdr.rcvif-if_type == IFT_CARP 
-   carp_lsdrop(m, AF_INET, icmpsrc.sin_addr.s_addr,
+   carp_lsdrop(m, AF_INET, sin.sin_addr.s_addr,
ip-ip_dst.s_addr))
goto freeit;
 #endif
@@ -492,7 +488,7 @@ icmp_input(struct mbuf *m, ...)
 */
ctlfunc = inetsw[ip_protox[icp-icmp_ip.ip_p]].pr_ctlinput;
if (ctlfunc)
-   (*ctlfunc)(code, sintosa(icmpsrc), m-m_pkthdr.rdomain,
+   (*ctlfunc)(code, sintosa(sin), m-m_pkthdr.rdomain,
icp-icmp_ip);
break;
 
@@ -538,14 +534,17 @@ icmp_input(struct mbuf *m, ...)
 * We are not able to respond with all ones broadcast
 * unless we receive it over a point-to-point interface.
 */
+   bzero(sin, sizeof(sin));
+   sin.sin_family = AF_INET;
+   sin.sin_len = sizeof(struct sockaddr_in);
if (ip-ip_dst.s_addr == INADDR_BROADCAST ||
ip-ip_dst.s_addr == INADDR_ANY)
-   icmpdst.sin_addr = ip-ip_src;
+   sin.sin_addr = ip-ip_src;
else
-   icmpdst.sin_addr = ip-ip_dst;
+   sin.sin_addr = ip-ip_dst;
if (m-m_pkthdr.rcvif == NULL)
break;
-   ia = ifatoia(ifaof_ifpforaddr(sintosa(icmpdst),
+   ia = ifatoia(ifaof_ifpforaddr(sintosa(sin),
m-m_pkthdr.rcvif));
if (ia == 0)
break;
@@ -579,6 +578,12 @@ reflect:
return;
 
case ICMP_REDIRECT:
+   {
+   struct sockaddr_in sdst;
+   struct sockaddr_in sgw;
+   struct sockaddr_in ssrc;
+   struct rtentry *newrt = NULL;
+
/* Free packet atttributes */
if (m-m_flags  M_PKTHDR)
m_tag_delete_chain(m);
@@ -598,8 +603,15 @@ reflect:
 * listening on a raw socket (e.g. the routing
 * daemon for use in updating its tables).
 */
-   icmpgw.sin_addr = ip-ip_src;
-   icmpdst.sin_addr = icp-icmp_gwaddr;
+   bzero(sdst, sizeof(sdst));
+   bzero(sgw, sizeof(sgw));
+   bzero(ssrc, sizeof(ssrc));
+   sdst.sin_family = sgw.sin_family = ssrc.sin_family = AF_INET;
+   sdst.sin_len = sgw.sin_len = ssrc.sin_len = sizeof(sdst);
+   bcopy(icp-icmp_ip.ip_dst, sdst.sin_addr, sizeof(sdst));
+   bcopy(icp-icmp_gwaddr, sgw.sin_addr, sizeof(sgw));
+   bcopy(ip-ip_src, ssrc.sin_addr, sizeof(ssrc));
+
 #ifdef ICMPPRINTFS
if (icmpprintfs) {
char buf[4 * sizeof(123)];
@@ -610,27 +622,25 @@ reflect:
buf, inet_ntoa(icp-icmp_gwaddr));
}
 #endif
-   icmpsrc.sin_addr = 

Re: tedu netatm

2013-08-09 Thread Mike Belopuhov
On 9 August 2013 09:36, Martin Pieuchot mpieuc...@nolizard.org wrote:
 It's me again :) With a freshly updated and tested diff to tedu netatm.
 I got no objection since I raised the issue 5 months ago [0], so I'm now
 looking for oks.

 [0] http://marc.info/?l=openbsd-techm=136335787207091w=2


i think it should go the way of doo doo.