Re: [Linuxptp-devel] [PATCH_SNMPD_v2 4/6] snmpd: Add snmp sub agent

2018-06-18 Thread Anders Selhammer
Friday, June 15, 2018 4:36 PM

> This won't work.  The 'dirs' are only the built in include paths from
> gcc, and the sysroot containing net-snmp-config will be somewhere
> else.

> Let's try something else:

> If CROSS_COMPILE is empty, just test `which net-snmp-config`, and if
> it doesn't fail, then use the output of net-snmp-config.

> If CROSS_COMPILE is non-empty, then check that `which net-snmp-config`
> is not /usr/bin/net-snmp-config.  If so, then use its output.

> If the user puts the sysroot's /usr/bin first in the PATH the we will
> have the correct net-snmp-config program.  That net-snmp-config is a
> shell script, and so it will run on the build machine in a cross
> environment.

I add this check is CROSS_COMPILE is unset, then I look for the h-files. 
If not found, snmpd will not be included. This will work in normal case but 
if you are in a cross compile environment it will just not be included. You 
can still compile. 


>I really want this series to go forward.  If you do the rest, I'll
>take care of the cross compilation issues.

Note that there are two libs that needs to be installed.
net-snmp and net-snmp-devel. 
If you only install the main lib, you will get access to the script but the libs
needed for the subagent will not be in place. This means that the script will 
probably provide the correct path but it will not find the libs when you try 
to link them in. So you need to really verify that they are in place.


Then since snmpd is a subagent, you need to start the master agent provided 
By the lib inorder to get the agent up and running properly.
The snmpd.conf needs to be replaced if you want access to the new 
implemented OIDs.


I will send in a v3 with updates for your other comments and this CROSS_COMPILE
unset check during the day.

/Anders


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


Re: [Linuxptp-devel] [PATCH_SNMPD_v2 4/6] snmpd: Add snmp sub agent

2018-06-16 Thread Richard Cochran
On Fri, Jun 15, 2018 at 12:30:15PM +, Anders Selhammer wrote:
> Will you be able to try this cross compiling and see if it works with the 
> updated 
> version (I can send in a updated version if that is the case)?

I really want this series to go forward.  If you do the rest, I'll
take care of the cross compilation issues.

Thanks,
Richard

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


Re: [Linuxptp-devel] [PATCH_SNMPD_v2 4/6] snmpd: Add snmp sub agent

2018-06-15 Thread Richard Cochran
On Fri, Jun 15, 2018 at 07:36:01AM -0700, Richard Cochran wrote:
> Yes, please post v2, and I will test it with cross compiling, with and

I mean, v3 of course.

Thanks,
Richard

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


Re: [Linuxptp-devel] [PATCH_SNMPD_v2 4/6] snmpd: Add snmp sub agent

2018-06-15 Thread Richard Cochran
On Fri, Jun 15, 2018 at 12:30:15PM +, Anders Selhammer wrote:
>   # Look for libsnmp presence
>   for d in $dirs; do
>   files=$(find $d -type f -name net-snmp-agent-includes.h)
>   for f in $files; do
>   if grep -q NET_SNMP_AGENT_INCLUDES_H $f; then
>   printf " `net-snmp-config --cflags`"

This won't work.  The 'dirs' are only the built in include paths from
gcc, and the sysroot containing net-snmp-config will be somewhere
else.

Let's try something else:

If CROSS_COMPILE is empty, just test `which net-snmp-config`, and if
it doesn't fail, then use the output of net-snmp-config.

If CROSS_COMPILE is non-empty, then check that `which net-snmp-config`
is not /usr/bin/net-snmp-config.  If so, then use its output.

If the user puts the sysroot's /usr/bin first in the PATH the we will
have the correct net-snmp-config program.  That net-snmp-config is a
shell script, and so it will run on the build machine in a cross
environment.

>   break 2

"break 2" - that's cute.  Didn't know you could do that.

>   fi
>   done
>   done

> A suggestion from the guy with the envir was to build a dummy program 
> including 
> the lib and neglect build errors (if any) from that build. If it succeeds, 
> build in snmp,
> otherwise skip it.

no, No, NO!

That is the path of autoconf madness, and we will never ever go there.
 
> I have not found anything that points to that netsnmp provide pkg-config 
> files.
> Neither google nor search in lib has given me anything that point in that 
> direction.

I checked libsnmp-dev in debian, and it doesn't have the pkg-config
.pc files.
 
> Will you be able to try this cross compiling and see if it works with the 
> updated 
> version (I can send in a updated version if that is the case)?

Yes, please post v2, and I will test it with cross compiling, with and
without libsnmp.  There are four cases:

   1. build machine doesn't have libsnmp, cross sysroot doesn't either
   2. build machine has libsnmp, cross sysroot doesn't
   3. build machine has libsnmp, cross sysroot does as well
   4. build machine doesn't have libsnmp, cross sysroot does have it

Thanks,
Richard

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


Re: [Linuxptp-devel] [PATCH_SNMPD_v2 4/6] snmpd: Add snmp sub agent

2018-06-15 Thread Anders Selhammer
Thursday, June 14, 2018 6:40 AM

> This won't work when cross compiling.  That is an important use case,
> and we should support it.

Will do the check like done for  clock_adjtime


user_flags()
{
# Needed for vasprintf().
printf " -D_GNU_SOURCE"

# Get list of directories searched for header files.
dirs=$(echo "" | ${CROSS_COMPILE}cpp -Wp,-v 2>&1 >/dev/null | grep ^" 
/")

# Look for clock_adjtime().
...

# Look for posix_spawn().
...

# Look for libsnmp presence
for d in $dirs; do
files=$(find $d -type f -name net-snmp-agent-includes.h)
for f in $files; do
if grep -q NET_SNMP_AGENT_INCLUDES_H $f; then
printf " `net-snmp-config --cflags`"
break 2
fi
done
done
}

Same goes for ldlibs.sh and optprg.sh



> Or is net-snmp-config a shell script (or similar) that delivers
> correct paths when cross compiling?

Im not that familiar with this cross compiling thing. I had the config script
net-snmp-config  tried in a cross-compiling environment and it did add extra
path information. If all of it is correct, I cannot say. 
What I was told by the guy with the envir was that if the lib and script are 
installed in the cross-compiling envir, it would probably work. 

A suggestion from the guy with the envir was to build a dummy program including 
the lib and neglect build errors (if any) from that build. If it succeeds, 
build in snmp,
otherwise skip it.

I have not found anything that points to that netsnmp provide pkg-config files.
Neither google nor search in lib has given me anything that point in that 
direction.

Will you be able to try this cross compiling and see if it works with the 
updated 
version (I can send in a updated version if that is the case)?

/Anders





--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


Re: [Linuxptp-devel] [PATCH_SNMPD_v2 4/6] snmpd: Add snmp sub agent

2018-06-14 Thread Richard Cochran
On Thu, Jun 14, 2018 at 07:14:05AM +, Anders Selhammer wrote:
> I did not add any printouts for this in the patch, but can off course add it. 

No need for that.  I was just curious, and I want to test this code
soon...

Thanks,
Richard

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


Re: [Linuxptp-devel] [PATCH_SNMPD_v2 4/6] snmpd: Add snmp sub agent

2018-06-14 Thread Anders Selhammer
Thursday, June 14, 2018 6:44 AM


> Please forgive my ignorance, but this minimal program is functional,
> right?
> What does it do?  How does one test it to see that it is working?

At this point, the subagent only register itself towards the master agent,
which is provided by the lib. It has not yet registered any OIDs so you
would not be able to test anything else than printouts of the result from
' agent_check_and_process' call. There are at least one alarm that is
Registered by default. Printing that can verify that the sub agent is up.

I did not add any printouts for this in the patch, but can off course add it. 
Removed it when I was done with my own testing.

Thanks,
Richard

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


Re: [Linuxptp-devel] [PATCH_SNMPD_v2 4/6] snmpd: Add snmp sub agent

2018-06-13 Thread Richard Cochran
On Tue, May 29, 2018 at 11:42:15PM +0200, Anders Selhammer wrote:
> +int main(int argc, char *argv[])
> +{
> + int err = 0;
> +
> + if (handle_term_signals()) {
> + return -1;
> + }
> +
> + if (open_snmp()) {
> + return -1;
> + }
> +
> + while (is_running()) {
> + agent_check_and_process(1);
> + }
> +
> + snmp_shutdown("linuxptpAgent");
> +
> + return err;
> +}

Please forgive my ignorance, but this minimal program is functional,
right?

What does it do?  How does one test it to see that it is working?

Thanks,
Richard

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


Re: [Linuxptp-devel] [PATCH_SNMPD_v2 4/6] snmpd: Add snmp sub agent

2018-06-13 Thread Richard Cochran
On Tue, May 29, 2018 at 11:42:15PM +0200, Anders Selhammer wrote:
> diff --git a/incdefs.sh b/incdefs.sh
> index 19e620e..d8ae7d5 100755
> --- a/incdefs.sh
> +++ b/incdefs.sh
> @@ -88,5 +88,16 @@ kernel_flags()
>   fi
>  }
>  
> -flags="$(user_flags)$(kernel_flags)"
> +#
> +# Look for libsnmp presence.
> +#
> +snmp_flags()
> +{
> + libsnmp=/usr/include/net-snmp/

This won't work when cross compiling.  That is an important use case,
and we should support it.

> + if [ -d ${libsnmp} ]; then
> + printf " -I. `net-snmp-config --cflags`"

Does libsnmp deliver pkgconfig files?  If so we can use them.

Or is net-snmp-config a shell script (or similar) that delivers
correct paths when cross compiling?

> + fi
> +}
> +
> +flags="$(user_flags)$(kernel_flags)$(snmp_flags)"
>  echo "$flags"

Thanks,
Richard

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel