ip6_mroute.c m_free() - m_freem()

2013-10-04 Thread Loganaden Velvindron
Hi,

I came across this small diff in netbsd. It fixes a small case of mbuf
leak possibility.

Index: sys/netinet6/ip6_mroute.c
===
RCS file: /cvs/src/sys/netinet6/ip6_mroute.c,v
retrieving revision 1.62
diff -u -p -r1.62 ip6_mroute.c
--- sys/netinet6/ip6_mroute.c   31 May 2013 15:04:24 -  1.62
+++ sys/netinet6/ip6_mroute.c   4 Oct 2013 07:04:50 -
@@ -503,7 +503,7 @@ ip6_mrouter_done(void)
for (rte = rt-mf6c_stall; rte != NULL; ) {
struct rtdetq *n = rte-next;
 
-   m_free(rte-m);
+   m_freem(rte-m);
free(rte, M_MRTABLE);
rte = n;
}



Re: Multicast macros and global list of addresses

2013-10-04 Thread Martin Pieuchot
On 02/10/13(Wed) 21:33, Stuart Henderson wrote:
 On 2013/09/19 13:59, Martin Pieuchot wrote:
  Diff below change the macros used to iterate over the multicast
  records linked to an interface without using the global lists of
  addresses.
  
  These records are currently link to the first address descriptor,
  respectively v4 and v6, even if they are per-interface.  So I
  changed the code to loop over the global interface list instead
  of iterating over all existing addresses.
  
  Tested here with a carp setup.  Comments, ok?
 
 No issues here with sapWatch, igmpproxy, dhcpd multicast sync, or
 typical ipv6 use. I haven't had chance to try ospfd/ospf6d yet though.

Thanks for testing.  Unless somebody object, I plan to commit this diff
next week, but oks are still welcome ;)

Martin



getifaddrs() netmasks with af=0 on vlan/lo

2013-10-04 Thread Stuart Henderson
It seems that for some interface types (I noticed vlan and lo), a netmask
with af==0 is returned by getifaddrs().

Not sure if this was always broken or introduced more recently; happens
on at least 5.3 and -current so it's not anything particularly recent.

Demonstration code (yes I know it's crappy but it does show the problem -
other code also hits it, I noticed this when investigating problems
reported with 'samenet' in postgresql).

-- --
#include sys/types.h
#include sys/socket.h
#include ifaddrs.h
#include stdio.h

void ntop(struct sockaddr *sa) {
char buf[128];

switch (sa-sa_family) {
case AF_INET:
printf(AF_INET );
break;
case AF_LINK:
printf(AF_LINK );
break;
case AF_INET6:
printf(AF_INET6 );
break;
default:
printf(AF[%u] , sa-sa_family);
}
inet_ntop(sa-sa_family, sa-sa_data+2, buf, sizeof(buf));
if (buf  (sa-sa_family != AF_LINK))
printf(%s, buf);
}

main() {
struct ifaddrs *ifa, *l;
if (getifaddrs(ifa)  0)
return 1;
for (l = ifa; l; l = l-ifa_next) {
printf(%s: , l-ifa_name);
ntop(l-ifa_addr);
if (l-ifa_netmask) {
printf( mask );
ntop(l-ifa_netmask);
}
printf(\n);
}
freeifaddrs(ifa);
}



Re: getifaddrs() netmasks with af=0 on vlan/lo

2013-10-04 Thread Martin Pieuchot
On 04/10/13(Fri) 11:46, Stuart Henderson wrote:
 It seems that for some interface types (I noticed vlan and lo), a netmask
 with af==0 is returned by getifaddrs().
 
 Not sure if this was always broken or introduced more recently; happens
 on at least 5.3 and -current so it's not anything particularly recent.
 
 Demonstration code (yes I know it's crappy but it does show the problem -
 other code also hits it, I noticed this when investigating problems
 reported with 'samenet' in postgresql).

I can reproduce this problem here for IPv4 and IPv6 addresses, but it
doesn't happen when the address is obtained with dhclient(8). 

This small ifconfig diff fixes it, not sure if it's the way to go,
but we might want to fix that in the kernel too.

Index: ifconfig.c
===
RCS file: /home/ncvs/src/sbin/ifconfig/ifconfig.c,v
retrieving revision 1.270
diff -u -p -r1.270 ifconfig.c
--- ifconfig.c  13 Sep 2013 14:32:53 -  1.270
+++ ifconfig.c  4 Oct 2013 11:22:32 -
@@ -4437,8 +4437,7 @@ in_getaddr(const char *s, int which)
 
bzero(tsin, sizeof(tsin));
sin-sin_len = sizeof(*sin);
-   if (which != MASK)
-   sin-sin_family = AF_INET;
+   sin-sin_family = AF_INET;
 
if (which == ADDR  strrchr(s, '/') != NULL 
(bits = inet_net_pton(AF_INET, s, tsin.sin_addr,
@@ -4472,8 +4471,7 @@ in_getprefix(const char *plen, int which
errx(1, prefix %s: %s, plen, errmsg);
 
sin-sin_len = sizeof(*sin);
-   if (which != MASK)
-   sin-sin_family = AF_INET;
+   sin-sin_family = AF_INET;
if ((len == 0) || (len == 32)) {
memset(sin-sin_addr, 0xff, sizeof(struct in_addr));
return;
@@ -4601,8 +4599,7 @@ in6_getprefix(const char *plen, int whic
errx(1, prefix %s: %s, plen, errmsg);
 
sin6-sin6_len = sizeof(*sin6);
-   if (which != MASK)
-   sin6-sin6_family = AF_INET6;
+   sin6-sin6_family = AF_INET6;
if ((len == 0) || (len == 128)) {
memset(sin6-sin6_addr, 0xff, sizeof(struct in6_addr));
return;



Re: ip6_mroute.c m_free() - m_freem()

2013-10-04 Thread Claudio Jeker
On Fri, Oct 04, 2013 at 12:17:41AM -0700, Loganaden Velvindron wrote:
 Hi,
 
 I came across this small diff in netbsd. It fixes a small case of mbuf
 leak possibility.
 

This is correct. OK claudio@

 Index: sys/netinet6/ip6_mroute.c
 ===
 RCS file: /cvs/src/sys/netinet6/ip6_mroute.c,v
 retrieving revision 1.62
 diff -u -p -r1.62 ip6_mroute.c
 --- sys/netinet6/ip6_mroute.c 31 May 2013 15:04:24 -  1.62
 +++ sys/netinet6/ip6_mroute.c 4 Oct 2013 07:04:50 -
 @@ -503,7 +503,7 @@ ip6_mrouter_done(void)
   for (rte = rt-mf6c_stall; rte != NULL; ) {
   struct rtdetq *n = rte-next;
  
 - m_free(rte-m);
 + m_freem(rte-m);
   free(rte, M_MRTABLE);
   rte = n;
   }
 

-- 
:wq Claudio



Re: getifaddrs() netmasks with af=0 on vlan/lo

2013-10-04 Thread Claudio Jeker
On Fri, Oct 04, 2013 at 11:46:42AM +0100, Stuart Henderson wrote:
 It seems that for some interface types (I noticed vlan and lo), a netmask
 with af==0 is returned by getifaddrs().
 
 Not sure if this was always broken or introduced more recently; happens
 on at least 5.3 and -current so it's not anything particularly recent.
 
 Demonstration code (yes I know it's crappy but it does show the problem -
 other code also hits it, I noticed this when investigating problems
 reported with 'samenet' in postgresql).

Hmm. People missing history class again and assuming the world is flat?
In the good old days netmasks did not have a family so that the
same entry could be used accross multiple AFs. The network stack still
produces them from time to time. This is why you need to use the AF of the
address to print the netmask. One can argue that this broken and I think
that you're right.
 
 -- --
 #include sys/types.h
 #include sys/socket.h
 #include ifaddrs.h
 #include stdio.h
 
 void ntop(struct sockaddr *sa) {
   char buf[128];
 
   switch (sa-sa_family) {
   case AF_INET:
   printf(AF_INET );
   break;
   case AF_LINK:
   printf(AF_LINK );
   break;
   case AF_INET6:
   printf(AF_INET6 );
   break;
   default:
   printf(AF[%u] , sa-sa_family);
   }
   inet_ntop(sa-sa_family, sa-sa_data+2, buf, sizeof(buf));
   if (buf  (sa-sa_family != AF_LINK))
   printf(%s, buf);
 }
 
 main() {
   struct ifaddrs *ifa, *l;
   if (getifaddrs(ifa)  0)
   return 1;
   for (l = ifa; l; l = l-ifa_next) {
   printf(%s: , l-ifa_name);
   ntop(l-ifa_addr);
   if (l-ifa_netmask) {
   printf( mask );
   ntop(l-ifa_netmask);
   }
   printf(\n);
   }
   freeifaddrs(ifa);
 }
 

-- 
:wq Claudio



Re: nouveau driver help

2013-10-04 Thread Jérémie Courrèges-Anglas

(Redirecting to tech@)

Roelof Wobben rwob...@hotmail.com writes:

 Hello,

Hi,

 To enjoy Gnome 3.10 fully I need the nouveau driver.
 But because this is my first attempt to make a port, 
 I wonder if someone can and is willing to help me.

I don't think that porting nouveau is a ports people concern (but rather
a concern for kernel and xenocara folks).

 I find out that FreeBSd has a port but that one is full of git
 commands.

I don't understand what this means.

-- 
jca | PGP: 0x06A11494 / 61DB D9A0 00A4 67CF 2A90  8961 6191 8FBF 06A1 1494



[lists-openbsdt...@bsws.de: Re: ip6_mroute.c m_free() - m_freem()]

2013-10-04 Thread Loganaden Velvindron
- Forwarded message from Henning Brauer lists-openbsdt...@bsws.de -

Date: Fri, 4 Oct 2013 13:34:26 +0200
From: Henning Brauer lists-openbsdt...@bsws.de
To: Loganaden Velvindron lo...@elandsys.com
Subject: Re: ip6_mroute.c m_free() - m_freem()
User-Agent: Mutt/1.5.21 (2010-09-15)

ok

-- 
Henning Brauer, h...@bsws.de, henn...@openbsd.org
BS Web Services GmbH, http://bsws.de, Full-Service ISP
Secure Hosting, Mail and DNS Services. Dedicated Servers, Root to Fully Managed
Henning Brauer Consulting, http://henningbrauer.com/

- End forwarded message -



Re: snmp client (aka walk)

2013-10-04 Thread Gabriel Guzman
On 10/01, Reyk Floeter wrote:
 Hi,
 
 I just committed a simple SNMP client implementation to snmpctl/snmpd.
 You can use it as an in-tree alternative to net-snmp's
 snmpwalk/snmpget.
 
 Examples:
 $ snmpctl walk 127.0.0.1
 $ snmpctl walk printer.my.domain version 1 oid printerWorkingGroup
 $ snmpctl -n walk 203.0.113.240 oid ifMIB community blah
 
 Limitations:
 - no SNMPv3/USM support yet
 - no bulk support yet (bulkwalk)
 - not so many fancy options.
 
 snmpd does not support loading of external MIB files, so you have to
 use net-snmp if you want to load additional MIBs for the symbolic name
 parsing.  snmpctl only shows symbolic names there are found in snmpd's
 mib.h.
 
 Testing welcome, especially with non-snmpd(8) agents.

Seems to work fine... only thing I have that's snmp walkable and not
snmpd is an HP printer: 

gabe@desktop:~$ snmpctl walk printer.my.domain 
system.sysDescr.0=HP ETHERNET MULTI-ENVIRONMENT
system.sysOID.0=iso.org.dod.internet.private.enterprises.hp.2.3.9.1
system.sysUpTime.0=4256
system.sysContact.0= 
system.sysName.0=printer
system.sysLocation.0=
system.sysServices.0=72
system.sysORLastChange.0=0
system.sysORTable.sysOREntry.sysORID.1=iso.org.dod.internet.snmpV2.snmpModules.snmpMIB
system.sysORTable.sysOREntry.sysORID.2=iso.org.dod.internet.snmpV2.snmpModules.framework.3.1.1
system.sysORTable.sysOREntry.sysORID.3=iso.org.dod.internet.snmpV2.snmpModules.11.3.1.1
system.sysORTable.sysOREntry.sysORID.4=iso.org.dod.internet.snmpV2.snmpModules.usm.2.1.1
system.sysORTable.sysOREntry.sysORID.5=iso.org.dod.internet.snmpV2.snmpModules.16.2.1.1
system.sysORTable.sysOREntry.sysORDescr.1=The MIB Module from SNMPv2
entities
system.sysORTable.sysOREntry.sysORDescr.2=SNMP Management Architecture
MIB
system.sysORTable.sysOREntry.sysORDescr.3=Message Processing and
Dispatching MIB
system.sysORTable.sysOREntry.sysORDescr.4=USM User MIB
system.sysORTable.sysOREntry.sysORDescr.5=VACM MIB
system.sysORTable.sysOREntry.sysORUpTime.1=0
system.sysORTable.sysOREntry.sysORUpTime.2=0
system.sysORTable.sysOREntry.sysORUpTime.3=0
system.sysORTable.sysOREntry.sysORUpTime.4=0
system.sysORTable.sysOREntry.sysORUpTime.5=0


Nice to have this in base!

gabe. 



Re: Promiscuous mode and multicast

2013-10-04 Thread Brad Smith
On Fri, Oct 04, 2013 at 03:18:45PM +0200, Martin Pieuchot wrote:
 tl;dr
 
   This diff stop (ab)using the actual SIOC{ADD,DEL}MULTI ioctls with a
 magic value for the whole range of multicast addresses used for IPv4/6
 to turn the interface into promiscuous mode.
 
 
 Long story
 
   Ethernet multicast records are currently represented by the ``struct
 ether_multi'' as range of addresses between enm_addrlo and enm_addrlhi.
 But most of the time this range represents a single address (lo == hi),
 and the only cases where this is not true are changed below.
 
 What happens in our drivers, is that as soon as the list of Ethernet
 multicast records associated to an interface contains a range, we set
 the IFF_ALLMULTI flag which turns the promiscuous mode on.  So the
 diff below directly set the interface into promiscuous mode instead
 of relying on this overcomplicated feature.

Well there is a difference between promiscuity for multicast traffic
and what is usually refered to as promiscuous mode.

 Apart from helping me to reduce the complexity of the multicast
 representation, which could be represented as one address instead of a
 range, this diff has another benefit.  With it, the IFF_ALLMULTI flag
 is now set on an interface only if we try to configure more multicast
 filters than it can handle (hardware limit).

The last part isn't true.

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.



Re: threaded prof signals

2013-10-04 Thread Ted Unangst
On Thu, Oct 03, 2013 at 18:12, Philip Guenther wrote:
 How about we take an idea from FreeBSD and have hardclock() just set a
 flag on the thread and then have the thread send SIGPROF (and SIGVTALRM)
 to itself from userret().  The signal gets sent by the thread itself right
 before it checks for pending signals when returning to userspace, so
 that's absolutely as soon as possible, and it's done from process context
 instead of from softclock by a timeout, so no which CPU are we on?
 issues that might delay the delivery.

I approve of all diffs that eliminate useless trampolines. I have no
idea if the diff works, but I will provisionally ok the idea.