Re: network interface/address API on FreeBSD

2015-03-04 Thread Niels Baggesen
Den 04-03-2015 kl. 10:17 skrev Gleb Smirnoff:
 I see, you use { CTL_NET, PF_ROUTE, 0, 0, NET_RT_IFLIST, 0 };

 I'd suggest to use getifaddrs(3), it uses more modern sysctl
 NET_RT_IFLISTL, note the L at end. And the library function
 takes the burden of parsing the stuff.

That looks interesting. I will give it try:-)

 Is it possible to disable compilation of deprecated IPV6-MIB implementation
 at compile time? It could be that would be just the right solution for
 future FreeBSD versions, instead of putting yet another ifdef into this
 awful pile of ifdefs, that I see in ipv6.c :)

./configure --with-out-mib-modules=mibII/ipv6

should do the trick

/Niels

-- 
Niels Baggesen - @home - Århus - Denmark - n...@users.sourceforge.net
The purpose of computing is insight, not numbers   ---   R W Hamming

--
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
___
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders


Re: network interface/address API on FreeBSD

2015-03-04 Thread Gleb Smirnoff
  Niels,

On Wed, Mar 04, 2015 at 09:06:11PM +0100, Niels Baggesen wrote:
N Den 04-03-2015 kl. 10:17 skrev Gleb Smirnoff:
N  I see, you use { CTL_NET, PF_ROUTE, 0, 0, NET_RT_IFLIST, 0 };
N 
N  I'd suggest to use getifaddrs(3), it uses more modern sysctl
N  NET_RT_IFLISTL, note the L at end. And the library function
N  takes the burden of parsing the stuff.
N 
N That looks interesting. I will give it try:-)

Thanks a lot! You can see example usage in the URLs that I posted
in the first email in this thread. If you move to getifaddrs(3),
that might make our life much easier in future.

NET_RT_IFLIST is considered somewhat internal API, between
kernel and libc. A year ago, we did run over all software in
FreeBSD ports collection to check whether any port uses it,
and look like a year ago no one did:

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=183357

N  Is it possible to disable compilation of deprecated IPV6-MIB implementation
N  at compile time? It could be that would be just the right solution for
N  future FreeBSD versions, instead of putting yet another ifdef into this
N  awful pile of ifdefs, that I see in ipv6.c :)
N 
N ./configure --with-out-mib-modules=mibII/ipv6
N 
N should do the trick

Will try that, thanks!

-- 
Totus tuus, Glebius.

--
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
___
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders


Re: network interface/address API on FreeBSD

2015-03-04 Thread Gleb Smirnoff
On Mon, Mar 02, 2015 at 09:33:30PM +0100, Niels Baggesen wrote:
N Den 27-02-2015 kl. 22:22 skrev Gleb Smirnoff:
N  Now time for net-snmp, which isn't piece of cake. And I'd like
N  to get it done properly, and not to store a patch in FreeBSD port
N  for ages, but to integrate the patch right in the main net-snmp repo.
N  So, I'm asking for your help here. Waiting for a net-snmp developer
N  to respond to this email, so that we can work on the problem together.
N 
N  P.S. This is doable, since native FreeBSD SNMP daemon implements
NmibII without utilizing kvm(3). :)
N 
N A lot of this changed between 5.7.2 and 5.7.3 to use sysctl interfaces.

I see, you use { CTL_NET, PF_ROUTE, 0, 0, NET_RT_IFLIST, 0 };

I'd suggest to use getifaddrs(3), it uses more modern sysctl
NET_RT_IFLISTL, note the L at end. And the library function
takes the burden of parsing the stuff.

N With the current 5.7.3 release, and configured with 
N --enable-mfd-rewrites, I think the only parts that uses kvm interfaces 
N are the old and deprecated IPV6-MIB implementations inmibII/ipv6.c, now 
N superseeded by the INET-XXX-MIB versions, and the hrSWRunTable that uses 
N kvm_getargv and kvm_getprocs.

Yes, mibII/ipv6.c is the place where build is broken right now, since
struct ifaddr is now hidden from userland programs. struct ifnet is
still visible, but soon to be hidden, too.

Is it possible to disable compilation of deprecated IPV6-MIB implementation
at compile time? It could be that would be just the right solution for
future FreeBSD versions, instead of putting yet another ifdef into this
awful pile of ifdefs, that I see in ipv6.c :)

-- 
Totus tuus, Glebius.

--
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
___
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders


network interface/address API on FreeBSD

2015-03-03 Thread Gleb Smirnoff
  Hi!

  [I'm not subscribed to the list, so please keep me in Cc]

I'm the guy, who often breaks compilation of net-snmp on FreeBSD,
changing layout of kernel structures. And I'm about to change them
even more this year. However, I'd like to keep net-snmp working.
But it looks like, I won't be able to do that without your help,
since patches are about to be not trivial.

In the first place, the idea to use kvm(3) library to read kernel
memory and traverse in kernel pointers was a very bad idea. The
library should actually be used only for debugging purposes, not
for production. It requires /dev/mem access, which implies increased
priveleges for application, making it less secure. It doesn't
participate in kernel locking, so any list traversals via
kernel pointers can eventually lead to accessing wrong memory.
The last, but not the least: it requires knowledge of the very
guts of kernel, and thus makes compilation of your program
very fragile as underlying system changes from release to release.

This ends in of tons of #ifdef __FreeBSD_version, __DragonFly_version,
OpenBSD_version, NetBSD_, etc., and uncomprehendable code finally.
I hope, everyone agrees on this.

Meanwhile, all BSD systems historically provided getifaddrs(3)
library function, that allows to obtain interface and address
information via a stable and non-priveleged API. Unfortunately,
most application developers constantly ignored getifaddrs(3) and
used kvm(3). My guess is that happened due to native netstat(1)
being kvm(3) based, and developers learned on how to obtain info
on network structures from its sources. They assumed that if
internal utility uses kvm(3), then this is the right way.

So, as part of my network stack work, I started to convert both
internal and external utilities to proper API:

https://svnweb.freebsd.org/base?view=revisionrevision=256512
https://github.com/miniupnp/miniupnp/commit/7f6cf3680e3fd539402c7576440cf7b1760ee088
http://freshbsd.org/commit/freebsd-ports/r369861
http://freshbsd.org/commit/freebsd-ports/r369851
http://freshbsd.org/commit/freebsd-ports/r369841
http://freshbsd.org/commit/freebsd-ports/r369827

Now time for net-snmp, which isn't piece of cake. And I'd like
to get it done properly, and not to store a patch in FreeBSD port
for ages, but to integrate the patch right in the main net-snmp repo.
So, I'm asking for your help here. Waiting for a net-snmp developer
to respond to this email, so that we can work on the problem together.

P.S. This is doable, since native FreeBSD SNMP daemon implements
 mibII without utilizing kvm(3). :)

-- 
Totus tuus, Glebius.

--
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
___
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders


Re: network interface/address API on FreeBSD

2015-03-03 Thread Gleb Smirnoff
On Mon, Mar 02, 2015 at 09:33:30PM +0100, Niels Baggesen wrote:
N Den 27-02-2015 kl. 22:22 skrev Gleb Smirnoff:
N  Now time for net-snmp, which isn't piece of cake. And I'd like
N  to get it done properly, and not to store a patch in FreeBSD port
N  for ages, but to integrate the patch right in the main net-snmp repo.
N  So, I'm asking for your help here. Waiting for a net-snmp developer
N  to respond to this email, so that we can work on the problem together.
N 
N  P.S. This is doable, since native FreeBSD SNMP daemon implements
NmibII without utilizing kvm(3). :)
N 
N A lot of this changed between 5.7.2 and 5.7.3 to use sysctl interfaces.
N 
N With the current 5.7.3 release, and configured with 
N --enable-mfd-rewrites, I think the only parts that uses kvm interfaces 
N are the old and deprecated IPV6-MIB implementations inmibII/ipv6.c, now 
N superseeded by the INET-XXX-MIB versions, and the hrSWRunTable that uses 
N kvm_getargv and kvm_getprocs.

What a good news! I will check build of latest net-snmp on latest FreeBSD
and report back.

-- 
Totus tuus, Glebius.

--
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
___
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders


Re: network interface/address API on FreeBSD

2015-03-02 Thread Niels Baggesen
Den 27-02-2015 kl. 22:22 skrev Gleb Smirnoff:
 Now time for net-snmp, which isn't piece of cake. And I'd like
 to get it done properly, and not to store a patch in FreeBSD port
 for ages, but to integrate the patch right in the main net-snmp repo.
 So, I'm asking for your help here. Waiting for a net-snmp developer
 to respond to this email, so that we can work on the problem together.

 P.S. This is doable, since native FreeBSD SNMP daemon implements
   mibII without utilizing kvm(3). :)

A lot of this changed between 5.7.2 and 5.7.3 to use sysctl interfaces.

With the current 5.7.3 release, and configured with 
--enable-mfd-rewrites, I think the only parts that uses kvm interfaces 
are the old and deprecated IPV6-MIB implementations inmibII/ipv6.c, now 
superseeded by the INET-XXX-MIB versions, and the hrSWRunTable that uses 
kvm_getargv and kvm_getprocs.

/Niels

-- 
Niels Baggesen -- @home -- Århus -- Denmark -- ni...@baggesen.net
The purpose of computing is insight, not numbers  --  R W Hamming

--
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
___
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders


network interface/address API on FreeBSD

2015-02-27 Thread Gleb Smirnoff
  Hi!

I'm the guy, who often breaks compilation of net-snmp on FreeBSD,
changing layout of kernel structures. And I'm about to change them
even more this year. However, I'd like to keep net-snmp working.
But it looks like, I won't be able to do that without your help,
since patches are about to be not trivial.

In the first place, the idea to use kvm(3) library to read kernel
memory and traverse in kernel pointers was a very bad idea. The
library should actually be used only for debugging purposes, not
for production. It requires /dev/mem access, which implies increased
priveleges for application, making it less secure. It doesn't
participate in kernel locking, so any list traversals via
kernel pointers can eventually lead to accessing wrong memory.
The last, but not the least: it requires knowledge of the very
guts of kernel, and thus makes compilation of your program
very fragile as underlying system changes from release to release.

This ends in of tons of #ifdef __FreeBSD_version, __DragonFly_version,
OpenBSD_version, NetBSD_, etc., and uncomprehendable code finally.
I hope, everyone agrees on this.

Meanwhile, all BSD systems historically provided getifaddrs(3)
library function, that allows to obtain interface and address
information via a stable and non-priveleged API. Unfortunately,
most application developers constantly ignored getifaddrs(3) and
used kvm(3). My guess is that happened due to native netstat(1)
being kvm(3) based, and developers learned on how to obtain info
on network structures from its sources. They assumed that if
internal utility uses kvm(3), then this is the right way.

So, as part of my network stack work, I started to convert both
internal and external utilities to proper API:

https://svnweb.freebsd.org/base?view=revisionrevision=256512
https://github.com/miniupnp/miniupnp/commit/7f6cf3680e3fd539402c7576440cf7b1760ee088
http://freshbsd.org/commit/freebsd-ports/r369861
http://freshbsd.org/commit/freebsd-ports/r369851
http://freshbsd.org/commit/freebsd-ports/r369841
http://freshbsd.org/commit/freebsd-ports/r369827

Now time for net-snmp, which isn't piece of cake. And I'd like
to get it done properly, and not to store a patch in FreeBSD port
for ages, but to integrate the patch right in the main net-snmp repo.
So, I'm asking for your help here. Waiting for a net-snmp developer
to respond to this email, so that we can work on the problem together.

P.S. This is doable, since native FreeBSD SNMP daemon implements
 mibII without utilizing kvm(3). :)

-- 
Totus tuus, Glebius.

--
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
___
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders