Re: Creating inetCidrRouteTable row entries
Den 21-01-2014 16:32, Daniel Tingstrom skrev: I couldn't find an existing function to convert a prefix length to a netmask, so I just wrote my own. Net SNMP version is 5.7.2. Here is the patch: Thanks for finding this! --- route_ioctl.c.old 2012-10-09 18:28:58.0 -0400 +++ route_ioctl.c 2014-01-21 10:30:32.239381288 -0500 @@ -114,7 +114,7 @@ DEBUGMSGTL((access:route,via %s\n, DEBUGSTR)); mask.sin_family = AF_INET; -mask.sin_addr.s_addr = htonl(0); +mask.sin_addr.s_addr = entry-rt_pfx_len ? htonl((( ((uint32_t)1) (32-entry-rt_pfx_len)) - 1) ^ 0xU) : 0; DEBUGSTR = inet_ntoa(mask.sin_addr); DEBUGMSGTL((access:route,mask %s\n, DEBUGSTR)); Thanks for the patch. I did create a function for converting prefix to mask, and it should be fixed the the next 5.7.3.pre release. /Niels -- Niels Baggesen - @home - Århus - Denmark - n...@users.sourceforge.net The purpose of computing is insight, not numbers --- R W Hamming -- CenturyLink Cloud: The Leader in Enterprise Cloud Services. Learn Why More Businesses Are Choosing CenturyLink Cloud For Critical Workloads, Development Environments Everything In Between. Get a Quote or Start a Free Trial Today. http://pubads.g.doubleclick.net/gampad/clk?id=119420431iu=/4140/ostg.clktrk ___ Net-snmp-coders mailing list Net-snmp-coders@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/net-snmp-coders
RE: Creating inetCidrRouteTable row entries
and it should be fixed the the next 5.7.3.pre release. That's great. I also found the same netmask problem in the route deletion method (_netsnmp_ioctl_route_delete_v4) which is in the same source file (route_ioctl.c). However, route deletion only works after a restart of snmpd, and crashes snmpd if a route was previously added during the same runtime instance. I think this issue lies with route caching, but I have not looked much into it. Regards, Daniel -Original Message- From: Niels Baggesen [mailto:n...@users.sourceforge.net] Sent: Monday, January 27, 2014 4:29 PM To: Daniel Tingstrom; net-snmp-coders@lists.sourceforge.net Subject: Re: Creating inetCidrRouteTable row entries Den 21-01-2014 16:32, Daniel Tingstrom skrev: I couldn't find an existing function to convert a prefix length to a netmask, so I just wrote my own. Net SNMP version is 5.7.2. Here is the patch: Thanks for finding this! --- route_ioctl.c.old 2012-10-09 18:28:58.0 -0400 +++ route_ioctl.c 2014-01-21 10:30:32.239381288 -0500 @@ -114,7 +114,7 @@ DEBUGMSGTL((access:route,via %s\n, DEBUGSTR)); mask.sin_family = AF_INET; -mask.sin_addr.s_addr = htonl(0); +mask.sin_addr.s_addr = entry-rt_pfx_len ? htonl((( ((uint32_t)1) + (32-entry-rt_pfx_len)) - 1) ^ 0xU) : 0; DEBUGSTR = inet_ntoa(mask.sin_addr); DEBUGMSGTL((access:route,mask %s\n, DEBUGSTR)); Thanks for the patch. I did create a function for converting prefix to mask, and it should be fixed the the next 5.7.3.pre release. /Niels -- Niels Baggesen - @home - Århus - Denmark - n...@users.sourceforge.net The purpose of computing is insight, not numbers --- R W Hamming smime.p7s Description: S/MIME cryptographic signature -- CenturyLink Cloud: The Leader in Enterprise Cloud Services. Learn Why More Businesses Are Choosing CenturyLink Cloud For Critical Workloads, Development Environments Everything In Between. Get a Quote or Start a Free Trial Today. http://pubads.g.doubleclick.net/gampad/clk?id=119420431iu=/4140/ostg.clktrk___ Net-snmp-coders mailing list Net-snmp-coders@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/net-snmp-coders
Creating inetCidrRouteTable row entries
Hi, I need to add a static route entry in linux via SNMP. So I am using inetCidrRouteTable. Unfortunately, the implementation of _netsnmp_ioctl_route_set_v4() in route_ioctl.c always hardcodes the route's netmask to 0.0.0.0, allowing only default gateway routes to be added. I had to manually change the following line: mask.sin_addr.s_addr = htonl(0); to: mask.sin_addr.s_addr = htonl(0x); for the following snmpset command to work: snmpset -l authPriv -A password -X password -a SHA -x AES -u authPrivUser localhost IP-FORWARD-MIB::inetCidrRouteStatus.1.4.20.20.0.0.16.2.0.0.1.4.10.10.0.1 i 4 IP-FORWARD-MIB::inetCidrRouteIfIndex.1.4.20.20.0.0.16.2.0.0.1.4.10.10.0.1 i 3 IP-FORWARD-MIB::inetCidrRouteMetric1.1.4.20.20.0.0.16.2.0.0.1.4.10.10.0.1 i 0 IP-FORWARD-MIB::inetCidrRouteType.1.4.20.20.0.0.16.2.0.0.1.4.10.10.0.1 i 4 I want to do the equivalent of: ip route add 20.20.0.0/16 via 10.10.0.1 I am new to SNMP and so I could be doing this wrong or making incorrect assumptions. Perhaps there is an alternative method to adding static routes that are not default gateways? Or is this simply a bug? Thanks, Daniel smime.p7s Description: S/MIME cryptographic signature -- CenturyLink Cloud: The Leader in Enterprise Cloud Services. Learn Why More Businesses Are Choosing CenturyLink Cloud For Critical Workloads, Development Environments Everything In Between. Get a Quote or Start a Free Trial Today. http://pubads.g.doubleclick.net/gampad/clk?id=119420431iu=/4140/ostg.clktrk___ Net-snmp-coders mailing list Net-snmp-coders@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/net-snmp-coders