Discussion:
[Ipmitool-devel] [ ipmitool-Bugs-3611253 ] Various bug-fixes
Dmitry Bazhenov
2013-04-18 05:49:20 UTC
Permalink
Hello, all,

The attached patch fixes several compile and run-time bugs in the
current ipmitool TOB:> o lib/ipmi_sel.c
- zero data before making request to avoid reading of uninitialized data
o lib/ipmi_mc.c
- do not print AUX info, if IPMC return 12-byte Get Device ID response
o lib/ipmi_picmg.c
- add support for hexadecimal and octal formats for the command-line parameters
o configure.in
- fixed build for the newer autotool releases
- do not override OS-default values for IMB, OPEN and LIPMI interfaces
if the corresponding enable/disable arguments are not provided in the command-line
Please, review.

Regards,
Dmitry
Zdenek Styblik
2013-04-18 07:42:07 UTC
Permalink
Post by Dmitry Bazhenov
Hello, all,
Hi,
Post by Dmitry Bazhenov
The attached patch fixes several compile and run-time bugs in the current
Post by Dmitry Bazhenov
o lib/ipmi_sel.c
- zero data before making request to avoid reading of uninitialized data
This looks ok.
Post by Dmitry Bazhenov
Post by Dmitry Bazhenov
o lib/ipmi_mc.c
- do not print AUX info, if IPMC return 12-byte Get Device ID
*shrug*
Post by Dmitry Bazhenov
Post by Dmitry Bazhenov
response
o lib/ipmi_picmg.c
- add support for hexadecimal and octal formats for the command-line
NACK. Yes, you're adding support for hex and oct, but it doesn't fix
possibility of over/under-flow. Please, add this to ID#3528310 and it
will get fixed along. Thanks!
If you're willing to take it further, please, write a generic function
to validate whether FRU ID is within acceptable range and use
apropriate str2* functions to convert string to integer. Such thing
would be "appreciated".
Post by Dmitry Bazhenov
Post by Dmitry Bazhenov
parameters
o configure.in
- fixed build for the newer autotool releases
I guess ACK.
Post by Dmitry Bazhenov
Post by Dmitry Bazhenov
- do not override OS-default values for IMB, OPEN and LIPMI interfaces
if the corresponding enable/disable arguments are not provided in
the command-line
NACK. Have you actually tested results of this patch? The way I see
it, fix is to create _os (defaults) variables and then:
``if test "x$xenable_intf_open" = "xyes" || test
"x$xenable_intf_open_os" = "xyes"; then''

I'll do the patch, eventually, if nobody else does it sooner(faster?).

Regards,
Z.
Post by Dmitry Bazhenov
Please, review.
Regards,
Dmitry
------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
Ipmitool-devel mailing list
https://lists.sourceforge.net/lists/listinfo/ipmitool-devel
Dmitry Bazhenov
2013-04-19 06:53:22 UTC
Permalink
Hello, Zdenek,

I addressed your comments. Please, review.
I put the changes into separate files this time.

In configure.ac I made default option values for all interfaces. So,
there should be no way some of them may be uninitialized.

Also, I re-arranged such that ipmishell is automatically disabled if
there are no its prerequisites.

In lib_picmg.c I corrected formatting and check all string to integer
conversions for errors.

Regards,
Dmitry
Post by Zdenek Styblik
Post by Dmitry Bazhenov
Hello, all,
Hi,
Post by Dmitry Bazhenov
The attached patch fixes several compile and run-time bugs in the current
Post by Dmitry Bazhenov
o lib/ipmi_sel.c
- zero data before making request to avoid reading of uninitialized data
This looks ok.
Post by Dmitry Bazhenov
Post by Dmitry Bazhenov
o lib/ipmi_mc.c
- do not print AUX info, if IPMC return 12-byte Get Device ID
*shrug*
Post by Dmitry Bazhenov
Post by Dmitry Bazhenov
response
o lib/ipmi_picmg.c
- add support for hexadecimal and octal formats for the command-line
NACK. Yes, you're adding support for hex and oct, but it doesn't fix
possibility of over/under-flow. Please, add this to ID#3528310 and it
will get fixed along. Thanks!
If you're willing to take it further, please, write a generic function
to validate whether FRU ID is within acceptable range and use
apropriate str2* functions to convert string to integer. Such thing
would be "appreciated".
Post by Dmitry Bazhenov
Post by Dmitry Bazhenov
parameters
o configure.in
- fixed build for the newer autotool releases
I guess ACK.
Post by Dmitry Bazhenov
Post by Dmitry Bazhenov
- do not override OS-default values for IMB, OPEN and LIPMI interfaces
if the corresponding enable/disable arguments are not provided in
the command-line
NACK. Have you actually tested results of this patch? The way I see
``if test "x$xenable_intf_open" = "xyes" || test
"x$xenable_intf_open_os" = "xyes"; then''
I'll do the patch, eventually, if nobody else does it sooner(faster?).
Regards,
Z.
Post by Dmitry Bazhenov
Please, review.
Regards,
Dmitry
------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
Ipmitool-devel mailing list
https://lists.sourceforge.net/lists/listinfo/ipmitool-devel
Dmitry Bazhenov
2013-04-23 04:36:21 UTC
Permalink
Hello, Zdenek,

Can I treat the patches as accepted or there are going to be other comments?

Regards,
Dmitry
Post by Dmitry Bazhenov
Hello, Zdenek,
I addressed your comments. Please, review.
I put the changes into separate files this time.
In configure.ac I made default option values for all interfaces. So,
there should be no way some of them may be uninitialized.
Also, I re-arranged such that ipmishell is automatically disabled if
there are no its prerequisites.
In lib_picmg.c I corrected formatting and check all string to integer
conversions for errors.
Regards,
Dmitry
On Thu, Apr 18, 2013 at 7:49 AM, Dmitry Bazhenov
Post by Dmitry Bazhenov
Hello, all,
Hi,
Post by Dmitry Bazhenov
The attached patch fixes several compile and run-time bugs in the current
Post by Dmitry Bazhenov
o lib/ipmi_sel.c
- zero data before making request to avoid reading of uninitialized data
This looks ok.
Post by Dmitry Bazhenov
Post by Dmitry Bazhenov
o lib/ipmi_mc.c
- do not print AUX info, if IPMC return 12-byte Get Device ID
*shrug*
Post by Dmitry Bazhenov
Post by Dmitry Bazhenov
response
o lib/ipmi_picmg.c
- add support for hexadecimal and octal formats for the command-line
NACK. Yes, you're adding support for hex and oct, but it doesn't fix
possibility of over/under-flow. Please, add this to ID#3528310 and it
will get fixed along. Thanks!
If you're willing to take it further, please, write a generic function
to validate whether FRU ID is within acceptable range and use
apropriate str2* functions to convert string to integer. Such thing
would be "appreciated".
Post by Dmitry Bazhenov
Post by Dmitry Bazhenov
parameters
o configure.in
- fixed build for the newer autotool releases
I guess ACK.
Post by Dmitry Bazhenov
Post by Dmitry Bazhenov
- do not override OS-default values for IMB, OPEN and LIPMI interfaces
if the corresponding enable/disable arguments are not provided in
the command-line
NACK. Have you actually tested results of this patch? The way I see
``if test "x$xenable_intf_open" = "xyes" || test
"x$xenable_intf_open_os" = "xyes"; then''
I'll do the patch, eventually, if nobody else does it sooner(faster?).
Regards,
Z.
Post by Dmitry Bazhenov
Please, review.
Regards,
Dmitry
------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
Ipmitool-devel mailing list
https://lists.sourceforge.net/lists/listinfo/ipmitool-devel
------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
Ipmitool-devel mailing list
https://lists.sourceforge.net/lists/listinfo/ipmitool-devel
Zdenek Styblik
2013-04-23 08:24:35 UTC
Permalink
Post by Dmitry Bazhenov
Hello, Zdenek,
Can I treat the patches as accepted or there are going to be other comments?
Regards,
Dmitry
Dmitry,

the following comments don't necessarily mean you have to re-do
things. They can be addressed by person doing commits. Some of them.

As for changes to configure, fix for build for the newer autotool
release is missing, but I can be scavenged from previous diff. No
worries, just don't forget about it. I don't fully agree with removing
OS defaults, resp. FreeBSD default of BMC, despite "global" defaults
are set above. I have one question about ipmishell and its
auto-disable and that's, what if user says he/she wants ipmishell, but
doesn't have all necessary prerequisites? Will configure fail or
silently disable ipmishell? My guess is it will silently disable
ipmishell and I'm not sure if this is a wanted behaviour.

Regarding changes to PICMG; if anything, they should be split into
two. I want to ask why change formatting at those particular lines,
but I guess it doesn't matter that much. As for replacement of
atoi()/strto*(), I'd like to work at it a bit. And as I said, these
will be tracked under ID#3528310.
What I want to change is:
* rephrase error messages
* move is_fru_id() function from 'ipmi_fru.c' to 'helper.c' and utilize it
* I don't know and may not find out what are allowed ranges for LED
related stuff, power level, present to desired, control option,
resource id etc., but these should be limited as well, not just
convert and "forward" to BMC. If you know ranges for any of these,
please, share.
* additionally replace all atoi()/strto*() calls; that's what
ID#3528310 is about anyway.

I have no comments on other diffs.

My $0.02 USD,
Z.
Post by Dmitry Bazhenov
Post by Dmitry Bazhenov
Hello, Zdenek,
I addressed your comments. Please, review.
I put the changes into separate files this time.
In configure.ac I made default option values for all interfaces. So,
there should be no way some of them may be uninitialized.
Also, I re-arranged such that ipmishell is automatically disabled if
there are no its prerequisites.
In lib_picmg.c I corrected formatting and check all string to integer
conversions for errors.
Regards,
Dmitry
On Thu, Apr 18, 2013 at 7:49 AM, Dmitry Bazhenov
Post by Dmitry Bazhenov
Hello, all,
Hi,
Post by Dmitry Bazhenov
The attached patch fixes several compile and run-time bugs in the current
Post by Dmitry Bazhenov
o lib/ipmi_sel.c
- zero data before making request to avoid reading of uninitialized data
This looks ok.
Post by Dmitry Bazhenov
Post by Dmitry Bazhenov
o lib/ipmi_mc.c
- do not print AUX info, if IPMC return 12-byte Get Device ID
*shrug*
Post by Dmitry Bazhenov
Post by Dmitry Bazhenov
response
o lib/ipmi_picmg.c
- add support for hexadecimal and octal formats for the command-line
NACK. Yes, you're adding support for hex and oct, but it doesn't fix
possibility of over/under-flow. Please, add this to ID#3528310 and it
will get fixed along. Thanks!
If you're willing to take it further, please, write a generic function
to validate whether FRU ID is within acceptable range and use
apropriate str2* functions to convert string to integer. Such thing
would be "appreciated".
Post by Dmitry Bazhenov
Post by Dmitry Bazhenov
parameters
o configure.in
- fixed build for the newer autotool releases
I guess ACK.
Post by Dmitry Bazhenov
Post by Dmitry Bazhenov
- do not override OS-default values for IMB, OPEN and LIPMI interfaces
if the corresponding enable/disable arguments are not provided in
the command-line
NACK. Have you actually tested results of this patch? The way I see
``if test "x$xenable_intf_open" = "xyes" || test
"x$xenable_intf_open_os" = "xyes"; then''
I'll do the patch, eventually, if nobody else does it sooner(faster?).
Regards,
Z.
Post by Dmitry Bazhenov
Please, review.
Regards,
Dmitry
------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
Ipmitool-devel mailing list
https://lists.sourceforge.net/lists/listinfo/ipmitool-devel
------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
Ipmitool-devel mailing list
https://lists.sourceforge.net/lists/listinfo/ipmitool-devel
------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_apr
_______________________________________________
Ipmitool-devel mailing list
https://lists.sourceforge.net/lists/listinfo/ipmitool-devel
Dmitry Bazhenov
2013-04-26 05:44:27 UTC
Permalink
Hello, Zdenek,

The updated patch to IPMITool works as follows.

By default, ipmishell is enabled (for linux as default OS). Then,
OS-defaults are applied.

If ipmishell remains enabled by default, its prerequisites are checked
and if the check fails, then ipmishell is disabled.

Next, the --enable-ipmishell command line parameter is checked (user
forces build status of ipmishell). If it enables ipmishell, then
prerequisites are checked once again and if the check fails, the
configure script fails as well.

I think that this is the most appropriate behavior for configure script
regarding the ipmishell.

Regards,
Dmitry
Post by Zdenek Styblik
Post by Dmitry Bazhenov
Hello, Zdenek,
Can I treat the patches as accepted or there are going to be other comments?
Regards,
Dmitry
Dmitry,
the following comments don't necessarily mean you have to re-do
things. They can be addressed by person doing commits. Some of them.
As for changes to configure, fix for build for the newer autotool
release is missing, but I can be scavenged from previous diff. No
worries, just don't forget about it. I don't fully agree with removing
OS defaults, resp. FreeBSD default of BMC, despite "global" defaults
are set above. I have one question about ipmishell and its
auto-disable and that's, what if user says he/she wants ipmishell, but
doesn't have all necessary prerequisites? Will configure fail or
silently disable ipmishell? My guess is it will silently disable
ipmishell and I'm not sure if this is a wanted behaviour.
Regarding changes to PICMG; if anything, they should be split into
two. I want to ask why change formatting at those particular lines,
but I guess it doesn't matter that much. As for replacement of
atoi()/strto*(), I'd like to work at it a bit. And as I said, these
will be tracked under ID#3528310.
* rephrase error messages
* move is_fru_id() function from 'ipmi_fru.c' to 'helper.c' and utilize it
* I don't know and may not find out what are allowed ranges for LED
related stuff, power level, present to desired, control option,
resource id etc., but these should be limited as well, not just
convert and "forward" to BMC. If you know ranges for any of these,
please, share.
* additionally replace all atoi()/strto*() calls; that's what
ID#3528310 is about anyway.
I have no comments on other diffs.
My $0.02 USD,
Z.
Post by Dmitry Bazhenov
Post by Dmitry Bazhenov
Hello, Zdenek,
I addressed your comments. Please, review.
I put the changes into separate files this time.
In configure.ac I made default option values for all interfaces. So,
there should be no way some of them may be uninitialized.
Also, I re-arranged such that ipmishell is automatically disabled if
there are no its prerequisites.
In lib_picmg.c I corrected formatting and check all string to integer
conversions for errors.
Regards,
Dmitry
On Thu, Apr 18, 2013 at 7:49 AM, Dmitry Bazhenov
Post by Dmitry Bazhenov
Hello, all,
Hi,
Post by Dmitry Bazhenov
The attached patch fixes several compile and run-time bugs in the current
Post by Dmitry Bazhenov
o lib/ipmi_sel.c
- zero data before making request to avoid reading of uninitialized data
This looks ok.
Post by Dmitry Bazhenov
Post by Dmitry Bazhenov
o lib/ipmi_mc.c
- do not print AUX info, if IPMC return 12-byte Get Device ID
*shrug*
Post by Dmitry Bazhenov
Post by Dmitry Bazhenov
response
o lib/ipmi_picmg.c
- add support for hexadecimal and octal formats for the command-line
NACK. Yes, you're adding support for hex and oct, but it doesn't fix
possibility of over/under-flow. Please, add this to ID#3528310 and it
will get fixed along. Thanks!
If you're willing to take it further, please, write a generic function
to validate whether FRU ID is within acceptable range and use
apropriate str2* functions to convert string to integer. Such thing
would be "appreciated".
Post by Dmitry Bazhenov
Post by Dmitry Bazhenov
parameters
o configure.in
- fixed build for the newer autotool releases
I guess ACK.
Post by Dmitry Bazhenov
Post by Dmitry Bazhenov
- do not override OS-default values for IMB, OPEN and LIPMI interfaces
if the corresponding enable/disable arguments are not provided in
the command-line
NACK. Have you actually tested results of this patch? The way I see
``if test "x$xenable_intf_open" = "xyes" || test
"x$xenable_intf_open_os" = "xyes"; then''
I'll do the patch, eventually, if nobody else does it sooner(faster?).
Regards,
Z.
Post by Dmitry Bazhenov
Please, review.
Regards,
Dmitry
------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
Ipmitool-devel mailing list
https://lists.sourceforge.net/lists/listinfo/ipmitool-devel
------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
Ipmitool-devel mailing list
https://lists.sourceforge.net/lists/listinfo/ipmitool-devel
------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_apr
_______________________________________________
Ipmitool-devel mailing list
https://lists.sourceforge.net/lists/listinfo/ipmitool-devel
Zdenek Styblik
2013-04-26 17:10:24 UTC
Permalink
Post by Dmitry Bazhenov
Hello, Zdenek,
The updated patch to IPMITool works as follows.
By default, ipmishell is enabled (for linux as default OS). Then,
OS-defaults are applied.
If ipmishell remains enabled by default, its prerequisites are checked and
if the check fails, then ipmishell is disabled.
Next, the --enable-ipmishell command line parameter is checked (user forces
build status of ipmishell). If it enables ipmishell, then prerequisites are
checked once again and if the check fails, the configure script fails as
well.
I think that this is the most appropriate behavior for configure script
regarding the ipmishell.
Regards,
Dmitry
Dmitry,

I see. Then I propose to change ipmishell description from 'yes' to
'auto' as well, agreed?

~~~
[AC_HELP_STRING([--enable-ipmishell],
[enable IPMI shell interface [default=yes]])],
~~~

I'd like to omit following change, as I said previously:
~~~
@@ -89,7 +97,6 @@ solaris*)
*freebsd*)
xenable_intf_imb=no
xenable_intf_lipmi=no
- xenable_intf_bmc=no
;;
*netbsd*)
xenable_intf_imb=no
~~~

is that ok?

Thanks,
Z.
Post by Dmitry Bazhenov
Post by Zdenek Styblik
Post by Dmitry Bazhenov
Hello, Zdenek,
Can I treat the patches as accepted or there are going to be other comments?
Regards,
Dmitry
Dmitry,
the following comments don't necessarily mean you have to re-do
things. They can be addressed by person doing commits. Some of them.
As for changes to configure, fix for build for the newer autotool
release is missing, but I can be scavenged from previous diff. No
worries, just don't forget about it. I don't fully agree with removing
OS defaults, resp. FreeBSD default of BMC, despite "global" defaults
are set above. I have one question about ipmishell and its
auto-disable and that's, what if user says he/she wants ipmishell, but
doesn't have all necessary prerequisites? Will configure fail or
silently disable ipmishell? My guess is it will silently disable
ipmishell and I'm not sure if this is a wanted behaviour.
Regarding changes to PICMG; if anything, they should be split into
two. I want to ask why change formatting at those particular lines,
but I guess it doesn't matter that much. As for replacement of
atoi()/strto*(), I'd like to work at it a bit. And as I said, these
will be tracked under ID#3528310.
* rephrase error messages
* move is_fru_id() function from 'ipmi_fru.c' to 'helper.c' and utilize it
* I don't know and may not find out what are allowed ranges for LED
related stuff, power level, present to desired, control option,
resource id etc., but these should be limited as well, not just
convert and "forward" to BMC. If you know ranges for any of these,
please, share.
* additionally replace all atoi()/strto*() calls; that's what
ID#3528310 is about anyway.
I have no comments on other diffs.
My $0.02 USD,
Z.
Post by Dmitry Bazhenov
Post by Dmitry Bazhenov
Hello, Zdenek,
I addressed your comments. Please, review.
I put the changes into separate files this time.
In configure.ac I made default option values for all interfaces. So,
there should be no way some of them may be uninitialized.
Also, I re-arranged such that ipmishell is automatically disabled if
there are no its prerequisites.
In lib_picmg.c I corrected formatting and check all string to integer
conversions for errors.
Regards,
Dmitry
On Thu, Apr 18, 2013 at 7:49 AM, Dmitry Bazhenov
Post by Dmitry Bazhenov
Hello, all,
Hi,
Post by Dmitry Bazhenov
The attached patch fixes several compile and run-time bugs in the current
Post by Dmitry Bazhenov
o lib/ipmi_sel.c
- zero data before making request to avoid reading of
uninitialized data
This looks ok.
Post by Dmitry Bazhenov
Post by Dmitry Bazhenov
o lib/ipmi_mc.c
- do not print AUX info, if IPMC return 12-byte Get Device ID
*shrug*
Post by Dmitry Bazhenov
Post by Dmitry Bazhenov
response
o lib/ipmi_picmg.c
- add support for hexadecimal and octal formats for the command-line
NACK. Yes, you're adding support for hex and oct, but it doesn't fix
possibility of over/under-flow. Please, add this to ID#3528310 and it
will get fixed along. Thanks!
If you're willing to take it further, please, write a generic function
to validate whether FRU ID is within acceptable range and use
apropriate str2* functions to convert string to integer. Such thing
would be "appreciated".
Post by Dmitry Bazhenov
Post by Dmitry Bazhenov
parameters
o configure.in
- fixed build for the newer autotool releases
I guess ACK.
Post by Dmitry Bazhenov
Post by Dmitry Bazhenov
- do not override OS-default values for IMB, OPEN and LIPMI interfaces
if the corresponding enable/disable arguments are not provided in
the command-line
NACK. Have you actually tested results of this patch? The way I see
``if test "x$xenable_intf_open" = "xyes" || test
"x$xenable_intf_open_os" = "xyes"; then''
I'll do the patch, eventually, if nobody else does it sooner(faster?).
Regards,
Z.
Post by Dmitry Bazhenov
Please, review.
Regards,
Dmitry
------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
Ipmitool-devel mailing list
https://lists.sourceforge.net/lists/listinfo/ipmitool-devel
------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
Ipmitool-devel mailing list
https://lists.sourceforge.net/lists/listinfo/ipmitool-devel
------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt!
http://p.sf.net/sfu/newrelic_d2d_apr
_______________________________________________
Ipmitool-devel mailing list
https://lists.sourceforge.net/lists/listinfo/ipmitool-devel
Dmitry Bazhenov
2013-04-26 17:23:09 UTC
Permalink
Hello, Zdenek,

No objections.

Dmitry
Post by Zdenek Styblik
Post by Dmitry Bazhenov
Hello, Zdenek,
The updated patch to IPMITool works as follows.
By default, ipmishell is enabled (for linux as default OS). Then,
OS-defaults are applied.
If ipmishell remains enabled by default, its prerequisites are checked and
if the check fails, then ipmishell is disabled.
Next, the --enable-ipmishell command line parameter is checked (user forces
build status of ipmishell). If it enables ipmishell, then prerequisites are
checked once again and if the check fails, the configure script fails as
well.
I think that this is the most appropriate behavior for configure script
regarding the ipmishell.
Regards,
Dmitry
Dmitry,
I see. Then I propose to change ipmishell description from 'yes' to
'auto' as well, agreed?
~~~
[AC_HELP_STRING([--enable-ipmishell],
[enable IPMI shell interface [default=yes]])],
~~~
~~~
@@ -89,7 +97,6 @@ solaris*)
*freebsd*)
xenable_intf_imb=no
xenable_intf_lipmi=no
- xenable_intf_bmc=no
;;
*netbsd*)
xenable_intf_imb=no
~~~
is that ok?
Thanks,
Z.
Post by Dmitry Bazhenov
Post by Zdenek Styblik
Post by Dmitry Bazhenov
Hello, Zdenek,
Can I treat the patches as accepted or there are going to be other comments?
Regards,
Dmitry
Dmitry,
the following comments don't necessarily mean you have to re-do
things. They can be addressed by person doing commits. Some of them.
As for changes to configure, fix for build for the newer autotool
release is missing, but I can be scavenged from previous diff. No
worries, just don't forget about it. I don't fully agree with removing
OS defaults, resp. FreeBSD default of BMC, despite "global" defaults
are set above. I have one question about ipmishell and its
auto-disable and that's, what if user says he/she wants ipmishell, but
doesn't have all necessary prerequisites? Will configure fail or
silently disable ipmishell? My guess is it will silently disable
ipmishell and I'm not sure if this is a wanted behaviour.
Regarding changes to PICMG; if anything, they should be split into
two. I want to ask why change formatting at those particular lines,
but I guess it doesn't matter that much. As for replacement of
atoi()/strto*(), I'd like to work at it a bit. And as I said, these
will be tracked under ID#3528310.
* rephrase error messages
* move is_fru_id() function from 'ipmi_fru.c' to 'helper.c' and utilize it
* I don't know and may not find out what are allowed ranges for LED
related stuff, power level, present to desired, control option,
resource id etc., but these should be limited as well, not just
convert and "forward" to BMC. If you know ranges for any of these,
please, share.
* additionally replace all atoi()/strto*() calls; that's what
ID#3528310 is about anyway.
I have no comments on other diffs.
My $0.02 USD,
Z.
Post by Dmitry Bazhenov
Post by Dmitry Bazhenov
Hello, Zdenek,
I addressed your comments. Please, review.
I put the changes into separate files this time.
In configure.ac I made default option values for all interfaces. So,
there should be no way some of them may be uninitialized.
Also, I re-arranged such that ipmishell is automatically disabled if
there are no its prerequisites.
In lib_picmg.c I corrected formatting and check all string to integer
conversions for errors.
Regards,
Dmitry
On Thu, Apr 18, 2013 at 7:49 AM, Dmitry Bazhenov
Post by Dmitry Bazhenov
Hello, all,
Hi,
Post by Dmitry Bazhenov
The attached patch fixes several compile and run-time bugs in the current
Post by Dmitry Bazhenov
o lib/ipmi_sel.c
- zero data before making request to avoid reading of
uninitialized data
This looks ok.
Post by Dmitry Bazhenov
Post by Dmitry Bazhenov
o lib/ipmi_mc.c
- do not print AUX info, if IPMC return 12-byte Get Device ID
*shrug*
Post by Dmitry Bazhenov
Post by Dmitry Bazhenov
response
o lib/ipmi_picmg.c
- add support for hexadecimal and octal formats for the command-line
NACK. Yes, you're adding support for hex and oct, but it doesn't fix
possibility of over/under-flow. Please, add this to ID#3528310 and it
will get fixed along. Thanks!
If you're willing to take it further, please, write a generic function
to validate whether FRU ID is within acceptable range and use
apropriate str2* functions to convert string to integer. Such thing
would be "appreciated".
Post by Dmitry Bazhenov
Post by Dmitry Bazhenov
parameters
o configure.in
- fixed build for the newer autotool releases
I guess ACK.
Post by Dmitry Bazhenov
Post by Dmitry Bazhenov
- do not override OS-default values for IMB, OPEN and LIPMI
interfaces
if the corresponding enable/disable arguments are not provided in
the command-line
NACK. Have you actually tested results of this patch? The way I see
``if test "x$xenable_intf_open" = "xyes" || test
"x$xenable_intf_open_os" = "xyes"; then''
I'll do the patch, eventually, if nobody else does it sooner(faster?).
Regards,
Z.
Post by Dmitry Bazhenov
Please, review.
Regards,
Dmitry
------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
Ipmitool-devel mailing list
https://lists.sourceforge.net/lists/listinfo/ipmitool-devel
------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
Ipmitool-devel mailing list
https://lists.sourceforge.net/lists/listinfo/ipmitool-devel
------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt!
http://p.sf.net/sfu/newrelic_d2d_apr
_______________________________________________
Ipmitool-devel mailing list
https://lists.sourceforge.net/lists/listinfo/ipmitool-devel
Dmitry Bazhenov
2013-04-26 10:08:38 UTC
Permalink
Hello, all,

I would like to submit a patch which adds Serial Basic and Terminal mode
interface drivers which utilize a direct serial connection in order to
interact with IPMC.

Both the patches implement single and double bridging. However, bridging
is temporarily broken for PICMG systems due to the known bridging
issues. I'm going to update the patch as soon as these issues are resolved.

Regards,
Dmitry
Dmitry Bazhenov
2013-05-17 11:52:43 UTC
Permalink
Hello, All!

I have updated the patch of direct serial drivers. Now single and double
bridging is working.

Also, I found several cases where "tmp_pass" string acquired from the
"getpass()" call is incorrectly freed. The getpass() function returns
address to a static buffer and freeing that address results in abrupt
program termination. I removed these free() calls altogether.

Please, review.

Regards,
Dmitry
Post by Dmitry Bazhenov
Hello, all,
I would like to submit a patch which adds Serial Basic and Terminal mode
interface drivers which utilize a direct serial connection in order to
interact with IPMC.
Both the patches implement single and double bridging. However, bridging
is temporarily broken for PICMG systems due to the known bridging
issues. I'm going to update the patch as soon as these issues are resolved.
Regards,
Dmitry
Zdenek Styblik
2013-05-19 15:21:24 UTC
Permalink
Post by Dmitry Bazhenov
Hello, All!
Hello Dmitry,

my comments are below.
Post by Dmitry Bazhenov
I have updated the patch of direct serial drivers. Now single and double
bridging is working.
Great. However, please fix the following lines:
+ rate = atol(p + 1);
+ rate = atol(p + 1);
+ rv = strtol(p + 4, &p, 16);
+ data[i++] = (unsigned char) strtol(str_hex, &pp, 16);

1] don't use atol()
2] since you have included 'ipmitool/helper.h' use appropriate str2*()
function(s) instead of atol() and strtol() and be done with it.

It seems to me like intf->session is leaking memory, resp. I don't see
it being freed anywhere.

There is a memory leak if '-D' is given more than once.

I'm also wondering whether /dev/tty or /dev/ttyS couldn't be implied
and whether extending 'struct ipmi_intf' is really necessary. But it's
just a silly question, I guess.
Post by Dmitry Bazhenov
Also, I found several cases where "tmp_pass" string acquired from the
"getpass()" call is incorrectly freed. The getpass() function returns
address to a static buffer and freeing that address results in abrupt
program termination. I removed these free() calls altogether.
Great, and I mean great. But let's do one thing at the time, ok? What
I mean is it should, has to, be submitted separately.
Also, I think your patch is incorrect. If this is issue *only* for
getpass(), then fix should be something like:
~~~
#ifdef HAVE_GETPASSPHRASE
free(tmp_pass);
#endif
~~~

Thanks,
Z.
Post by Dmitry Bazhenov
Please, review.
Regards,
Dmitry
Post by Dmitry Bazhenov
Hello, all,
I would like to submit a patch which adds Serial Basic and Terminal mode
interface drivers which utilize a direct serial connection in order to
interact with IPMC.
Both the patches implement single and double bridging. However, bridging
is temporarily broken for PICMG systems due to the known bridging
issues. I'm going to update the patch as soon as these issues are resolved.
Regards,
Dmitry
------------------------------------------------------------------------------
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d
_______________________________________________
Ipmitool-devel mailing list
https://lists.sourceforge.net/lists/listinfo/ipmitool-devel
Dmitry Bazhenov
2013-05-20 04:31:37 UTC
Permalink
Hello, Zdenek,

Thanks for review. Please, see below.
Post by Zdenek Styblik
Post by Dmitry Bazhenov
Hello, All!
Hello Dmitry,
my comments are below.
Post by Dmitry Bazhenov
I have updated the patch of direct serial drivers. Now single and double
bridging is working.
+ rate = atol(p + 1);
+ rate = atol(p + 1);
+ rv = strtol(p + 4, &p, 16);
+ data[i++] = (unsigned char) strtol(str_hex, &pp, 16);
I have changed atol() calls to str2uint().
Unfortunately, ipmitool/helper.h does not provide appropriate API to
replace strtol(). In the code strtol() is called with radix=16 that
means the input is read in hexadecimal form only. I think it is best to
leave the strtol() calls there as they are.
Post by Zdenek Styblik
1] don't use atol()
2] since you have included 'ipmitool/helper.h' use appropriate str2*()
function(s) instead of atol() and strtol() and be done with it.
It seems to me like intf->session is leaking memory, resp. I don't see
it being freed anywhere.
Fixed.
Post by Zdenek Styblik
There is a memory leak if '-D' is given more than once.
Fixed.
Post by Zdenek Styblik
I'm also wondering whether /dev/tty or /dev/ttyS couldn't be implied
and whether extending 'struct ipmi_intf' is really necessary. But it's
just a silly question, I guess.
I couldn't find a better solution to provide a device string to the
drivers. The implying /dev/tty(s, USB) strings in the command-line is
possible. I'll think through how to make it without affecting those
users who get used to specify the full device names.
Post by Zdenek Styblik
Post by Dmitry Bazhenov
Also, I found several cases where "tmp_pass" string acquired from the
"getpass()" call is incorrectly freed. The getpass() function returns
address to a static buffer and freeing that address results in abrupt
program termination. I removed these free() calls altogether.
Great, and I mean great. But let's do one thing at the time, ok? What
I mean is it should, has to, be submitted separately.
Also, I think your patch is incorrect. If this is issue *only* for
~~~
#ifdef HAVE_GETPASSPHRASE
free(tmp_pass);
#endif
~~~
These two functions both return a pointer to the static data. Hence, the
#ifdef guard is unnecessary.

I'll provide the updated patch for serial drivers and separate patch for
the bug soon.

No more comments below.

Regards,
Dmitry
Post by Zdenek Styblik
Thanks,
Z.
Post by Dmitry Bazhenov
Please, review.
Regards,
Dmitry
Post by Dmitry Bazhenov
Hello, all,
I would like to submit a patch which adds Serial Basic and Terminal mode
interface drivers which utilize a direct serial connection in order to
interact with IPMC.
Both the patches implement single and double bridging. However, bridging
is temporarily broken for PICMG systems due to the known bridging
issues. I'm going to update the patch as soon as these issues are resolved.
Regards,
Dmitry
------------------------------------------------------------------------------
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d
_______________________________________________
Ipmitool-devel mailing list
https://lists.sourceforge.net/lists/listinfo/ipmitool-devel
Zdenek Styblik
2013-05-20 04:46:42 UTC
Permalink
On Mon, May 20, 2013 at 6:31 AM, Dmitry Bazhenov <***@pigeonpoint.com> wrote:
[...]
Post by Dmitry Bazhenov
Post by Zdenek Styblik
+ rate = atol(p + 1);
+ rate = atol(p + 1);
+ rv = strtol(p + 4, &p, 16);
+ data[i++] = (unsigned char) strtol(str_hex, &pp, 16);
I have changed atol() calls to str2uint().
Unfortunately, ipmitool/helper.h does not provide appropriate API to replace
strtol(). In the code strtol() is called with radix=16 that means the input
is read in hexadecimal form only. I think it is best to leave the strtol()
calls there as they are.
I see. Well, this sucks. Two solutions come to my mind. The first is
to extend str2*() calls which, I admit, is going to be a bit of work.
The second is to check 'errno', endptr and '#include <limits.h>'. In
other words, do what str2*() calls do.

[...]
Post by Dmitry Bazhenov
Post by Zdenek Styblik
I'm also wondering whether /dev/tty or /dev/ttyS couldn't be implied
and whether extending 'struct ipmi_intf' is really necessary. But it's
just a silly question, I guess.
I couldn't find a better solution to provide a device string to the drivers.
The implying /dev/tty(s, USB) strings in the command-line is possible. I'll
think through how to make it without affecting those users who get used to
specify the full device names.
No, you're right. Serial dev can have <whatever> name. I guess it's
fine as it's.

[...]
Post by Dmitry Bazhenov
These two functions both return a pointer to the static data. Hence, the
#ifdef guard is unnecessary.
Hmm :-S Ok. To be honest, I'm disappointed, because this means
possible memory leak which "can't" be fixed.

Thanks,
Z.
Post by Dmitry Bazhenov
I'll provide the updated patch for serial drivers and separate patch for the
bug soon.
No more comments below.
Regards,
Dmitry
Post by Zdenek Styblik
Thanks,
Z.
Post by Dmitry Bazhenov
Please, review.
Regards,
Dmitry
Post by Dmitry Bazhenov
Hello, all,
I would like to submit a patch which adds Serial Basic and Terminal mode
interface drivers which utilize a direct serial connection in order to
interact with IPMC.
Both the patches implement single and double bridging. However, bridging
is temporarily broken for PICMG systems due to the known bridging
issues. I'm going to update the patch as soon as these issues are resolved.
Regards,
Dmitry
------------------------------------------------------------------------------
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d
_______________________________________________
Ipmitool-devel mailing list
https://lists.sourceforge.net/lists/listinfo/ipmitool-devel
Dmitry Bazhenov
2013-05-20 12:17:39 UTC
Permalink
Hello, Zdenek,

I've addressed your comments.
Post by Zdenek Styblik
I see. Well, this sucks. Two solutions come to my mind. The first is
to extend str2*() calls which, I admit, is going to be a bit of work.
The second is to check 'errno', endptr and '#include <limits.h>'. In
other words, do what str2*() calls do.
I added checks of endptr and errno after the strtol() calls. In the
context of these two calls these checks look sufficient to me. Please,
review.

Regards,
Dmitry
Post by Zdenek Styblik
[...]
Post by Dmitry Bazhenov
Post by Zdenek Styblik
+ rate = atol(p + 1);
+ rate = atol(p + 1);
+ rv = strtol(p + 4, &p, 16);
+ data[i++] = (unsigned char) strtol(str_hex, &pp, 16);
I have changed atol() calls to str2uint().
Unfortunately, ipmitool/helper.h does not provide appropriate API to replace
strtol(). In the code strtol() is called with radix=16 that means the input
is read in hexadecimal form only. I think it is best to leave the strtol()
calls there as they are.
I see. Well, this sucks. Two solutions come to my mind. The first is
to extend str2*() calls which, I admit, is going to be a bit of work.
The second is to check 'errno', endptr and '#include <limits.h>'. In
other words, do what str2*() calls do.
[...]
Post by Dmitry Bazhenov
Post by Zdenek Styblik
I'm also wondering whether /dev/tty or /dev/ttyS couldn't be implied
and whether extending 'struct ipmi_intf' is really necessary. But it's
just a silly question, I guess.
I couldn't find a better solution to provide a device string to the drivers.
The implying /dev/tty(s, USB) strings in the command-line is possible. I'll
think through how to make it without affecting those users who get used to
specify the full device names.
No, you're right. Serial dev can have <whatever> name. I guess it's
fine as it's.
[...]
Post by Dmitry Bazhenov
These two functions both return a pointer to the static data. Hence, the
#ifdef guard is unnecessary.
Hmm :-S Ok. To be honest, I'm disappointed, because this means
possible memory leak which "can't" be fixed.
Thanks,
Z.
Post by Dmitry Bazhenov
I'll provide the updated patch for serial drivers and separate patch for the
bug soon.
No more comments below.
Regards,
Dmitry
Post by Zdenek Styblik
Thanks,
Z.
Post by Dmitry Bazhenov
Please, review.
Regards,
Dmitry
Post by Dmitry Bazhenov
Hello, all,
I would like to submit a patch which adds Serial Basic and Terminal mode
interface drivers which utilize a direct serial connection in order to
interact with IPMC.
Both the patches implement single and double bridging. However, bridging
is temporarily broken for PICMG systems due to the known bridging
issues. I'm going to update the patch as soon as these issues are resolved.
Regards,
Dmitry
------------------------------------------------------------------------------
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d
_______________________________________________
Ipmitool-devel mailing list
https://lists.sourceforge.net/lists/listinfo/ipmitool-devel
Dmitry Bazhenov
2013-05-20 12:24:12 UTC
Permalink
Zdenek,
Post by Dmitry Bazhenov
Also, I found several cases where "tmp_pass" string acquired from the
"getpass()" call is incorrectly freed. The getpass() function returns
address to a static buffer and freeing that address results in abrupt
program termination. I removed these free() calls altogether.
Regards,
Dmitry
Zdenek Styblik
2013-05-20 12:50:52 UTC
Permalink
Post by Dmitry Bazhenov
Hello, Zdenek,
I've addressed your comments.
Post by Zdenek Styblik
I see. Well, this sucks. Two solutions come to my mind. The first is
to extend str2*() calls which, I admit, is going to be a bit of work.
The second is to check 'errno', endptr and '#include <limits.h>'. In
other words, do what str2*() calls do.
I added checks of endptr and errno after the strtol() calls. In the context
of these two calls these checks look sufficient to me. Please, review.
Regards,
Dmitry
Dmitry,

please, see changes I've made/I propose. Lines which don't
being/aren't prefixed with '+' got either changed or added. Also, some
parts of the code are missing, but since you have written it, it
shouldn't be a problem.
If you have any questions regarding changes I've made, please, ask.

+static int
+recv_response(struct ipmi_intf * intf, unsigned char *data, int len)
+{
+ char hex_rs[IPMI_SERIAL_MAX_RESPONSE * 3];
int i, j, resp_len = 0;
/* This shouldn't matter since rv isn't used further in the
code, is it? */
long int rv = 0;
unsigned long int hex_tmp = 0;
[...]
+ if (strncmp(p, "ERR ", 4) == 0) {
+ serial_write_line(intf, "\r\r\r\r");
+ sleep(1);
+ serial_flush(intf);
errno = 0;
rv = strtol(p + 4, &p, 16);
+ if ((rv && rv < 0x100 && *p == '\0')
+ || (rv == 0 && !errno)) {
+ /* The message didn't get it through. The upper
+ level will have to re-send */
+ return 0;
+ } else {
+ lprintf(LOG_ERR, "Serial response is invalid");
+ return -1;
+ }
+ }
+ /* parse the response */
+ i = 0;
+ j = 0;
+ while (*p) {
[...]
+ if (j == 2) {
+ /* parse the hex number */
+ str_hex[j] = 0;
errno = 0;
hex_tmp = strtoul(str_hex, &pp, 16);
/* I'm not 100% sure about "|| *pp != '\0' " here.
Please, test it! */
if (errno != 0 || hex_tmp > UCHAR_MAX || *pp != '\0') {
/* TODO - Handle this error */
}
data[i++] = hex_tmp;
+ if (pp == str_hex || *pp != 0) {
+ break;
+ }
+ j = 0;
+ }
[...]

Best regards,
Z.
Post by Dmitry Bazhenov
Post by Zdenek Styblik
[...]
Post by Dmitry Bazhenov
Post by Zdenek Styblik
+ rate = atol(p + 1);
+ rate = atol(p + 1);
+ rv = strtol(p + 4, &p, 16);
+ data[i++] = (unsigned char) strtol(str_hex, &pp, 16);
I have changed atol() calls to str2uint().
Unfortunately, ipmitool/helper.h does not provide appropriate API to replace
strtol(). In the code strtol() is called with radix=16 that means the input
is read in hexadecimal form only. I think it is best to leave the strtol()
calls there as they are.
I see. Well, this sucks. Two solutions come to my mind. The first is
to extend str2*() calls which, I admit, is going to be a bit of work.
The second is to check 'errno', endptr and '#include <limits.h>'. In
other words, do what str2*() calls do.
[...]
Post by Dmitry Bazhenov
Post by Zdenek Styblik
I'm also wondering whether /dev/tty or /dev/ttyS couldn't be implied
and whether extending 'struct ipmi_intf' is really necessary. But it's
just a silly question, I guess.
I couldn't find a better solution to provide a device string to the drivers.
The implying /dev/tty(s, USB) strings in the command-line is possible. I'll
think through how to make it without affecting those users who get used to
specify the full device names.
No, you're right. Serial dev can have <whatever> name. I guess it's
fine as it's.
[...]
Post by Dmitry Bazhenov
These two functions both return a pointer to the static data. Hence, the
#ifdef guard is unnecessary.
Hmm :-S Ok. To be honest, I'm disappointed, because this means
possible memory leak which "can't" be fixed.
Thanks,
Z.
Post by Dmitry Bazhenov
I'll provide the updated patch for serial drivers and separate patch for the
bug soon.
No more comments below.
Regards,
Dmitry
Post by Zdenek Styblik
Thanks,
Z.
Post by Dmitry Bazhenov
Please, review.
Regards,
Dmitry
Post by Dmitry Bazhenov
Hello, all,
I would like to submit a patch which adds Serial Basic and Terminal mode
interface drivers which utilize a direct serial connection in order to
interact with IPMC.
Both the patches implement single and double bridging. However, bridging
is temporarily broken for PICMG systems due to the known bridging
issues. I'm going to update the patch as soon as these issues are resolved.
Regards,
Dmitry
------------------------------------------------------------------------------
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d
_______________________________________________
Ipmitool-devel mailing list
https://lists.sourceforge.net/lists/listinfo/ipmitool-devel
Dmitry Bazhenov
2013-05-20 13:07:09 UTC
Permalink
Zdenek,

I agree with the first fragment changes (probably, it is worth making
"rv" an unsigned long).

As for the second fragment, I suggest we remove any check at all. The
surrounding context ensures that the converted string is a 2-digit
hexadecimal (see the isxdigit(ch) check upper to the fragment).

Regards,
Dmitry
Post by Zdenek Styblik
Post by Dmitry Bazhenov
Hello, Zdenek,
I've addressed your comments.
Post by Zdenek Styblik
I see. Well, this sucks. Two solutions come to my mind. The first is
to extend str2*() calls which, I admit, is going to be a bit of work.
The second is to check 'errno', endptr and '#include <limits.h>'. In
other words, do what str2*() calls do.
I added checks of endptr and errno after the strtol() calls. In the context
of these two calls these checks look sufficient to me. Please, review.
Regards,
Dmitry
Dmitry,
please, see changes I've made/I propose. Lines which don't
being/aren't prefixed with '+' got either changed or added. Also, some
parts of the code are missing, but since you have written it, it
shouldn't be a problem.
If you have any questions regarding changes I've made, please, ask.
+static int
+recv_response(struct ipmi_intf * intf, unsigned char *data, int len)
+{
+ char hex_rs[IPMI_SERIAL_MAX_RESPONSE * 3];
int i, j, resp_len = 0;
/* This shouldn't matter since rv isn't used further in the
code, is it? */
long int rv = 0;
unsigned long int hex_tmp = 0;
[...]
+ if (strncmp(p, "ERR ", 4) == 0) {
+ serial_write_line(intf, "\r\r\r\r");
+ sleep(1);
+ serial_flush(intf);
errno = 0;
rv = strtol(p + 4, &p, 16);
+ if ((rv && rv < 0x100 && *p == '\0')
+ || (rv == 0 && !errno)) {
+ /* The message didn't get it through. The upper
+ level will have to re-send */
+ return 0;
+ } else {
+ lprintf(LOG_ERR, "Serial response is invalid");
+ return -1;
+ }
+ }
+ /* parse the response */
+ i = 0;
+ j = 0;
+ while (*p) {
[...]
+ if (j == 2) {
+ /* parse the hex number */
+ str_hex[j] = 0;
errno = 0;
hex_tmp = strtoul(str_hex, &pp, 16);
/* I'm not 100% sure about "|| *pp != '\0' " here.
Please, test it! */
if (errno != 0 || hex_tmp > UCHAR_MAX || *pp != '\0') {
/* TODO - Handle this error */
}
data[i++] = hex_tmp;
+ if (pp == str_hex || *pp != 0) {
+ break;
+ }
+ j = 0;
+ }
[...]
Best regards,
Z.
Post by Dmitry Bazhenov
Post by Zdenek Styblik
[...]
Post by Dmitry Bazhenov
Post by Zdenek Styblik
+ rate = atol(p + 1);
+ rate = atol(p + 1);
+ rv = strtol(p + 4, &p, 16);
+ data[i++] = (unsigned char) strtol(str_hex, &pp, 16);
I have changed atol() calls to str2uint().
Unfortunately, ipmitool/helper.h does not provide appropriate API to replace
strtol(). In the code strtol() is called with radix=16 that means the input
is read in hexadecimal form only. I think it is best to leave the strtol()
calls there as they are.
I see. Well, this sucks. Two solutions come to my mind. The first is
to extend str2*() calls which, I admit, is going to be a bit of work.
The second is to check 'errno', endptr and '#include <limits.h>'. In
other words, do what str2*() calls do.
[...]
Post by Dmitry Bazhenov
Post by Zdenek Styblik
I'm also wondering whether /dev/tty or /dev/ttyS couldn't be implied
and whether extending 'struct ipmi_intf' is really necessary. But it's
just a silly question, I guess.
I couldn't find a better solution to provide a device string to the drivers.
The implying /dev/tty(s, USB) strings in the command-line is possible. I'll
think through how to make it without affecting those users who get used to
specify the full device names.
No, you're right. Serial dev can have <whatever> name. I guess it's
fine as it's.
[...]
Post by Dmitry Bazhenov
These two functions both return a pointer to the static data. Hence, the
#ifdef guard is unnecessary.
Hmm :-S Ok. To be honest, I'm disappointed, because this means
possible memory leak which "can't" be fixed.
Thanks,
Z.
Post by Dmitry Bazhenov
I'll provide the updated patch for serial drivers and separate patch for the
bug soon.
No more comments below.
Regards,
Dmitry
Post by Zdenek Styblik
Thanks,
Z.
Post by Dmitry Bazhenov
Please, review.
Regards,
Dmitry
Post by Dmitry Bazhenov
Hello, all,
I would like to submit a patch which adds Serial Basic and Terminal mode
interface drivers which utilize a direct serial connection in order to
interact with IPMC.
Both the patches implement single and double bridging. However, bridging
is temporarily broken for PICMG systems due to the known bridging
issues. I'm going to update the patch as soon as these issues are resolved.
Regards,
Dmitry
------------------------------------------------------------------------------
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d
_______________________________________________
Ipmitool-devel mailing list
https://lists.sourceforge.net/lists/listinfo/ipmitool-devel
Zdenek Styblik
2013-05-20 13:32:54 UTC
Permalink
Post by Dmitry Bazhenov
Zdenek,
I agree with the first fragment changes (probably, it is worth making "rv"
an unsigned long).
Dmitry,

it was just a quick modification to show what I meant.
Post by Dmitry Bazhenov
As for the second fragment, I suggest we remove any check at all. The
surrounding context ensures that the converted string is a 2-digit
hexadecimal (see the isxdigit(ch) check upper to the fragment).
Uh. I'd be rather safe than sorry. My $0.02 USD.

Best regards,
Z.
Post by Dmitry Bazhenov
Regards,
Dmitry
Post by Zdenek Styblik
Post by Dmitry Bazhenov
Hello, Zdenek,
I've addressed your comments.
Post by Zdenek Styblik
I see. Well, this sucks. Two solutions come to my mind. The first is
to extend str2*() calls which, I admit, is going to be a bit of work.
The second is to check 'errno', endptr and '#include <limits.h>'. In
other words, do what str2*() calls do.
I added checks of endptr and errno after the strtol() calls. In the context
of these two calls these checks look sufficient to me. Please, review.
Regards,
Dmitry
Dmitry,
please, see changes I've made/I propose. Lines which don't
being/aren't prefixed with '+' got either changed or added. Also, some
parts of the code are missing, but since you have written it, it
shouldn't be a problem.
If you have any questions regarding changes I've made, please, ask.
+static int
+recv_response(struct ipmi_intf * intf, unsigned char *data, int len)
+{
+ char hex_rs[IPMI_SERIAL_MAX_RESPONSE * 3];
int i, j, resp_len = 0;
/* This shouldn't matter since rv isn't used further in the
code, is it? */
long int rv = 0;
unsigned long int hex_tmp = 0;
[...]
+ if (strncmp(p, "ERR ", 4) == 0) {
+ serial_write_line(intf, "\r\r\r\r");
+ sleep(1);
+ serial_flush(intf);
errno = 0;
rv = strtol(p + 4, &p, 16);
+ if ((rv && rv < 0x100 && *p == '\0')
+ || (rv == 0 && !errno)) {
+ /* The message didn't get it through. The upper
+ level will have to re-send */
+ return 0;
+ } else {
+ lprintf(LOG_ERR, "Serial response is invalid");
+ return -1;
+ }
+ }
+ /* parse the response */
+ i = 0;
+ j = 0;
+ while (*p) {
[...]
+ if (j == 2) {
+ /* parse the hex number */
+ str_hex[j] = 0;
errno = 0;
hex_tmp = strtoul(str_hex, &pp, 16);
/* I'm not 100% sure about "|| *pp != '\0' " here.
Please, test it! */
if (errno != 0 || hex_tmp > UCHAR_MAX || *pp != '\0') {
/* TODO - Handle this error */
}
data[i++] = hex_tmp;
+ if (pp == str_hex || *pp != 0) {
+ break;
+ }
+ j = 0;
+ }
[...]
Best regards,
Z.
Post by Dmitry Bazhenov
Post by Zdenek Styblik
On Mon, May 20, 2013 at 6:31 AM, Dmitry Bazhenov
[...]
Post by Dmitry Bazhenov
Post by Zdenek Styblik
+ rate = atol(p + 1);
+ rate = atol(p + 1);
+ rv = strtol(p + 4, &p, 16);
+ data[i++] = (unsigned char) strtol(str_hex,
&pp,
16);
I have changed atol() calls to str2uint().
Unfortunately, ipmitool/helper.h does not provide appropriate API to replace
strtol(). In the code strtol() is called with radix=16 that means the input
is read in hexadecimal form only. I think it is best to leave the strtol()
calls there as they are.
I see. Well, this sucks. Two solutions come to my mind. The first is
to extend str2*() calls which, I admit, is going to be a bit of work.
The second is to check 'errno', endptr and '#include <limits.h>'. In
other words, do what str2*() calls do.
[...]
Post by Dmitry Bazhenov
Post by Zdenek Styblik
I'm also wondering whether /dev/tty or /dev/ttyS couldn't be implied
and whether extending 'struct ipmi_intf' is really necessary. But it's
just a silly question, I guess.
I couldn't find a better solution to provide a device string to the drivers.
The implying /dev/tty(s, USB) strings in the command-line is possible. I'll
think through how to make it without affecting those users who get used to
specify the full device names.
No, you're right. Serial dev can have <whatever> name. I guess it's
fine as it's.
[...]
Post by Dmitry Bazhenov
These two functions both return a pointer to the static data. Hence, the
#ifdef guard is unnecessary.
Hmm :-S Ok. To be honest, I'm disappointed, because this means
possible memory leak which "can't" be fixed.
Thanks,
Z.
Post by Dmitry Bazhenov
I'll provide the updated patch for serial drivers and separate patch for
the
bug soon.
No more comments below.
Regards,
Dmitry
Post by Zdenek Styblik
Thanks,
Z.
Post by Dmitry Bazhenov
Please, review.
Regards,
Dmitry
Post by Dmitry Bazhenov
Hello, all,
I would like to submit a patch which adds Serial Basic and Terminal mode
interface drivers which utilize a direct serial connection in order to
interact with IPMC.
Both the patches implement single and double bridging. However, bridging
is temporarily broken for PICMG systems due to the known bridging
issues. I'm going to update the patch as soon as these issues are resolved.
Regards,
Dmitry
------------------------------------------------------------------------------
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d
_______________________________________________
Ipmitool-devel mailing list
https://lists.sourceforge.net/lists/listinfo/ipmitool-devel
Dmitry Bazhenov
2013-05-21 08:44:16 UTC
Permalink
Hello, Zdenek,

Can I assume that the patch has passed the review and will be applied to
the mainline anytime soon? Or there are some actions from my side
pending to be done?

Regards,
Dmitry
Post by Zdenek Styblik
Post by Dmitry Bazhenov
Zdenek,
I agree with the first fragment changes (probably, it is worth making "rv"
an unsigned long).
Dmitry,
it was just a quick modification to show what I meant.
Post by Dmitry Bazhenov
As for the second fragment, I suggest we remove any check at all. The
surrounding context ensures that the converted string is a 2-digit
hexadecimal (see the isxdigit(ch) check upper to the fragment).
Uh. I'd be rather safe than sorry. My $0.02 USD.
Best regards,
Z.
Post by Dmitry Bazhenov
Regards,
Dmitry
Post by Zdenek Styblik
Post by Dmitry Bazhenov
Hello, Zdenek,
I've addressed your comments.
Post by Zdenek Styblik
I see. Well, this sucks. Two solutions come to my mind. The first is
to extend str2*() calls which, I admit, is going to be a bit of work.
The second is to check 'errno', endptr and '#include <limits.h>'. In
other words, do what str2*() calls do.
I added checks of endptr and errno after the strtol() calls. In the context
of these two calls these checks look sufficient to me. Please, review.
Regards,
Dmitry
Dmitry,
please, see changes I've made/I propose. Lines which don't
being/aren't prefixed with '+' got either changed or added. Also, some
parts of the code are missing, but since you have written it, it
shouldn't be a problem.
If you have any questions regarding changes I've made, please, ask.
+static int
+recv_response(struct ipmi_intf * intf, unsigned char *data, int len)
+{
+ char hex_rs[IPMI_SERIAL_MAX_RESPONSE * 3];
int i, j, resp_len = 0;
/* This shouldn't matter since rv isn't used further in the
code, is it? */
long int rv = 0;
unsigned long int hex_tmp = 0;
[...]
+ if (strncmp(p, "ERR ", 4) == 0) {
+ serial_write_line(intf, "\r\r\r\r");
+ sleep(1);
+ serial_flush(intf);
errno = 0;
rv = strtol(p + 4, &p, 16);
+ if ((rv && rv < 0x100 && *p == '\0')
+ || (rv == 0 && !errno)) {
+ /* The message didn't get it through. The upper
+ level will have to re-send */
+ return 0;
+ } else {
+ lprintf(LOG_ERR, "Serial response is invalid");
+ return -1;
+ }
+ }
+ /* parse the response */
+ i = 0;
+ j = 0;
+ while (*p) {
[...]
+ if (j == 2) {
+ /* parse the hex number */
+ str_hex[j] = 0;
errno = 0;
hex_tmp = strtoul(str_hex, &pp, 16);
/* I'm not 100% sure about "|| *pp != '\0' " here.
Please, test it! */
if (errno != 0 || hex_tmp > UCHAR_MAX || *pp != '\0') {
/* TODO - Handle this error */
}
data[i++] = hex_tmp;
+ if (pp == str_hex || *pp != 0) {
+ break;
+ }
+ j = 0;
+ }
[...]
Best regards,
Z.
Post by Dmitry Bazhenov
Post by Zdenek Styblik
On Mon, May 20, 2013 at 6:31 AM, Dmitry Bazhenov
[...]
Post by Dmitry Bazhenov
Post by Zdenek Styblik
+ rate = atol(p + 1);
+ rate = atol(p + 1);
+ rv = strtol(p + 4, &p, 16);
+ data[i++] = (unsigned char) strtol(str_hex,
&pp,
16);
I have changed atol() calls to str2uint().
Unfortunately, ipmitool/helper.h does not provide appropriate API to replace
strtol(). In the code strtol() is called with radix=16 that means the input
is read in hexadecimal form only. I think it is best to leave the strtol()
calls there as they are.
I see. Well, this sucks. Two solutions come to my mind. The first is
to extend str2*() calls which, I admit, is going to be a bit of work.
The second is to check 'errno', endptr and '#include <limits.h>'. In
other words, do what str2*() calls do.
[...]
Post by Dmitry Bazhenov
Post by Zdenek Styblik
I'm also wondering whether /dev/tty or /dev/ttyS couldn't be implied
and whether extending 'struct ipmi_intf' is really necessary. But it's
just a silly question, I guess.
I couldn't find a better solution to provide a device string to the drivers.
The implying /dev/tty(s, USB) strings in the command-line is possible. I'll
think through how to make it without affecting those users who get used to
specify the full device names.
No, you're right. Serial dev can have <whatever> name. I guess it's
fine as it's.
[...]
Post by Dmitry Bazhenov
These two functions both return a pointer to the static data. Hence, the
#ifdef guard is unnecessary.
Hmm :-S Ok. To be honest, I'm disappointed, because this means
possible memory leak which "can't" be fixed.
Thanks,
Z.
Post by Dmitry Bazhenov
I'll provide the updated patch for serial drivers and separate patch for
the
bug soon.
No more comments below.
Regards,
Dmitry
Post by Zdenek Styblik
Thanks,
Z.
Post by Dmitry Bazhenov
Please, review.
Regards,
Dmitry
Post by Dmitry Bazhenov
Hello, all,
I would like to submit a patch which adds Serial Basic and Terminal mode
interface drivers which utilize a direct serial connection in order to
interact with IPMC.
Both the patches implement single and double bridging. However, bridging
is temporarily broken for PICMG systems due to the known bridging
issues. I'm going to update the patch as soon as these issues are resolved.
Regards,
Dmitry
------------------------------------------------------------------------------
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d
_______________________________________________
Ipmitool-devel mailing list
https://lists.sourceforge.net/lists/listinfo/ipmitool-devel
Zdenek Styblik
2013-05-21 10:45:42 UTC
Permalink
On Tue, May 21, 2013 at 10:44 AM, Dmitry Bazhenov
Post by Dmitry Bazhenov
Hello, Zdenek,
Can I assume that the patch has passed the review and will be applied to the
mainline anytime soon?
Hello Dmitry,

well, I've looked at it. If you want to call it a review, sure :)
I'm wondering whether you insist on not checking the second strtol()
call. Also, whether you want to change 'rv' to unsigned long as
mentioned couple e-mails ago.
Is there some extra documentation necessary/required (and available)
so this can be used/implemented/supported by other parties? But I
pretty much guessed this is just shoveling IPMI packets over serial
line, am I correct?
Post by Dmitry Bazhenov
Or there are some actions from my side pending to be
done?
None I know of.

Thanks,
Z.
Post by Dmitry Bazhenov
Regards,
Dmitry
Post by Zdenek Styblik
Post by Dmitry Bazhenov
Zdenek,
I agree with the first fragment changes (probably, it is worth making "rv"
an unsigned long).
Dmitry,
it was just a quick modification to show what I meant.
Post by Dmitry Bazhenov
As for the second fragment, I suggest we remove any check at all. The
surrounding context ensures that the converted string is a 2-digit
hexadecimal (see the isxdigit(ch) check upper to the fragment).
Uh. I'd be rather safe than sorry. My $0.02 USD.
Best regards,
Z.
Post by Dmitry Bazhenov
Regards,
Dmitry
On Mon, May 20, 2013 at 2:17 PM, Dmitry Bazhenov
Post by Dmitry Bazhenov
Hello, Zdenek,
I've addressed your comments.
Post by Zdenek Styblik
I see. Well, this sucks. Two solutions come to my mind. The first is
to extend str2*() calls which, I admit, is going to be a bit of work.
The second is to check 'errno', endptr and '#include <limits.h>'. In
other words, do what str2*() calls do.
I added checks of endptr and errno after the strtol() calls. In the context
of these two calls these checks look sufficient to me. Please, review.
Regards,
Dmitry
Dmitry,
please, see changes I've made/I propose. Lines which don't
being/aren't prefixed with '+' got either changed or added. Also, some
parts of the code are missing, but since you have written it, it
shouldn't be a problem.
If you have any questions regarding changes I've made, please, ask.
+static int
+recv_response(struct ipmi_intf * intf, unsigned char *data, int len)
+{
+ char hex_rs[IPMI_SERIAL_MAX_RESPONSE * 3];
int i, j, resp_len = 0;
/* This shouldn't matter since rv isn't used further in the
code, is it? */
long int rv = 0;
unsigned long int hex_tmp = 0;
[...]
+ if (strncmp(p, "ERR ", 4) == 0) {
+ serial_write_line(intf, "\r\r\r\r");
+ sleep(1);
+ serial_flush(intf);
errno = 0;
rv = strtol(p + 4, &p, 16);
+ if ((rv && rv < 0x100 && *p == '\0')
+ || (rv == 0 && !errno)) {
+ /* The message didn't get it through. The upper
+ level will have to re-send */
+ return 0;
+ } else {
+ lprintf(LOG_ERR, "Serial response is invalid");
+ return -1;
+ }
+ }
+ /* parse the response */
+ i = 0;
+ j = 0;
+ while (*p) {
[...]
+ if (j == 2) {
+ /* parse the hex number */
+ str_hex[j] = 0;
errno = 0;
hex_tmp = strtoul(str_hex, &pp, 16);
/* I'm not 100% sure about "|| *pp != '\0' " here.
Please, test it! */
if (errno != 0 || hex_tmp > UCHAR_MAX || *pp != '\0') {
/* TODO - Handle this error */
}
data[i++] = hex_tmp;
+ if (pp == str_hex || *pp != 0) {
+ break;
+ }
+ j = 0;
+ }
[...]
Best regards,
Z.
Post by Dmitry Bazhenov
Post by Zdenek Styblik
On Mon, May 20, 2013 at 6:31 AM, Dmitry Bazhenov
[...]
Post by Dmitry Bazhenov
Post by Zdenek Styblik
+ rate = atol(p + 1);
+ rate = atol(p + 1);
+ rv = strtol(p + 4, &p, 16);
+ data[i++] = (unsigned char) strtol(str_hex,
&pp,
16);
I have changed atol() calls to str2uint().
Unfortunately, ipmitool/helper.h does not provide appropriate API to replace
strtol(). In the code strtol() is called with radix=16 that means the input
is read in hexadecimal form only. I think it is best to leave the strtol()
calls there as they are.
I see. Well, this sucks. Two solutions come to my mind. The first is
to extend str2*() calls which, I admit, is going to be a bit of work.
The second is to check 'errno', endptr and '#include <limits.h>'. In
other words, do what str2*() calls do.
[...]
Post by Dmitry Bazhenov
Post by Zdenek Styblik
I'm also wondering whether /dev/tty or /dev/ttyS couldn't be implied
and whether extending 'struct ipmi_intf' is really necessary. But it's
just a silly question, I guess.
I couldn't find a better solution to provide a device string to the drivers.
The implying /dev/tty(s, USB) strings in the command-line is
possible.
I'll
think through how to make it without affecting those users who get
used
to
specify the full device names.
No, you're right. Serial dev can have <whatever> name. I guess it's
fine as it's.
[...]
Post by Dmitry Bazhenov
These two functions both return a pointer to the static data. Hence, the
#ifdef guard is unnecessary.
Hmm :-S Ok. To be honest, I'm disappointed, because this means
possible memory leak which "can't" be fixed.
Thanks,
Z.
Post by Dmitry Bazhenov
I'll provide the updated patch for serial drivers and separate patch for
the
bug soon.
No more comments below.
Regards,
Dmitry
Post by Zdenek Styblik
Thanks,
Z.
Post by Dmitry Bazhenov
Please, review.
Regards,
Dmitry
Post by Dmitry Bazhenov
Hello, all,
I would like to submit a patch which adds Serial Basic and
Terminal
mode
interface drivers which utilize a direct serial connection in
order
to
interact with IPMC.
Both the patches implement single and double bridging. However, bridging
is temporarily broken for PICMG systems due to the known bridging
issues. I'm going to update the patch as soon as these issues are
resolved.
Regards,
Dmitry
------------------------------------------------------------------------------
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities.
Easily
and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d
_______________________________________________
Ipmitool-devel mailing list
https://lists.sourceforge.net/lists/listinfo/ipmitool-devel
Dmitry Bazhenov
2013-05-21 14:18:01 UTC
Permalink
Zdenek,
Post by Zdenek Styblik
On Tue, May 21, 2013 at 10:44 AM, Dmitry Bazhenov
Post by Dmitry Bazhenov
Hello, Zdenek,
Can I assume that the patch has passed the review and will be applied to the
mainline anytime soon?
Hello Dmitry,
well, I've looked at it. If you want to call it a review, sure :)
I'm wondering whether you insist on not checking the second strtol()
call. Also, whether you want to change 'rv' to unsigned long as
mentioned couple e-mails ago.
I would like not to place excessive check there in order not to overload
the code. The surrounding context pretty much ensures that the
conversion goes smoothly without errors.
Post by Zdenek Styblik
Is there some extra documentation necessary/required (and available)
so this can be used/implemented/supported by other parties? But I
pretty much guessed this is just shoveling IPMI packets over serial
line, am I correct?
You are correct. It's just a way to interact with IPM Controllers. I
don't think that anything more than the help string is required here.
Post by Zdenek Styblik
Post by Dmitry Bazhenov
Or there are some actions from my side pending to be
done?
None I know of.
Good. Can you acknowledge that the patch will be submitted into the
mainline?

No more comments below.

Regards,
Dmitry
Post by Zdenek Styblik
Thanks,
Z.
Post by Dmitry Bazhenov
Regards,
Dmitry
Post by Zdenek Styblik
Post by Dmitry Bazhenov
Zdenek,
I agree with the first fragment changes (probably, it is worth making "rv"
an unsigned long).
Dmitry,
it was just a quick modification to show what I meant.
Post by Dmitry Bazhenov
As for the second fragment, I suggest we remove any check at all. The
surrounding context ensures that the converted string is a 2-digit
hexadecimal (see the isxdigit(ch) check upper to the fragment).
Uh. I'd be rather safe than sorry. My $0.02 USD.
Best regards,
Z.
Post by Dmitry Bazhenov
Regards,
Dmitry
On Mon, May 20, 2013 at 2:17 PM, Dmitry Bazhenov
Post by Dmitry Bazhenov
Hello, Zdenek,
I've addressed your comments.
Post by Zdenek Styblik
I see. Well, this sucks. Two solutions come to my mind. The first is
to extend str2*() calls which, I admit, is going to be a bit of work.
The second is to check 'errno', endptr and '#include <limits.h>'. In
other words, do what str2*() calls do.
I added checks of endptr and errno after the strtol() calls. In the context
of these two calls these checks look sufficient to me. Please, review.
Regards,
Dmitry
Dmitry,
please, see changes I've made/I propose. Lines which don't
being/aren't prefixed with '+' got either changed or added. Also, some
parts of the code are missing, but since you have written it, it
shouldn't be a problem.
If you have any questions regarding changes I've made, please, ask.
+static int
+recv_response(struct ipmi_intf * intf, unsigned char *data, int len)
+{
+ char hex_rs[IPMI_SERIAL_MAX_RESPONSE * 3];
int i, j, resp_len = 0;
/* This shouldn't matter since rv isn't used further in the
code, is it? */
long int rv = 0;
unsigned long int hex_tmp = 0;
[...]
+ if (strncmp(p, "ERR ", 4) == 0) {
+ serial_write_line(intf, "\r\r\r\r");
+ sleep(1);
+ serial_flush(intf);
errno = 0;
rv = strtol(p + 4, &p, 16);
+ if ((rv && rv < 0x100 && *p == '\0')
+ || (rv == 0 && !errno)) {
+ /* The message didn't get it through. The upper
+ level will have to re-send */
+ return 0;
+ } else {
+ lprintf(LOG_ERR, "Serial response is invalid");
+ return -1;
+ }
+ }
+ /* parse the response */
+ i = 0;
+ j = 0;
+ while (*p) {
[...]
+ if (j == 2) {
+ /* parse the hex number */
+ str_hex[j] = 0;
errno = 0;
hex_tmp = strtoul(str_hex, &pp, 16);
/* I'm not 100% sure about "|| *pp != '\0' " here.
Please, test it! */
if (errno != 0 || hex_tmp > UCHAR_MAX || *pp != '\0') {
/* TODO - Handle this error */
}
data[i++] = hex_tmp;
+ if (pp == str_hex || *pp != 0) {
+ break;
+ }
+ j = 0;
+ }
[...]
Best regards,
Z.
Post by Dmitry Bazhenov
Post by Zdenek Styblik
On Mon, May 20, 2013 at 6:31 AM, Dmitry Bazhenov
[...]
Post by Dmitry Bazhenov
Post by Zdenek Styblik
+ rate = atol(p + 1);
+ rate = atol(p + 1);
+ rv = strtol(p + 4, &p, 16);
+ data[i++] = (unsigned char) strtol(str_hex,
&pp,
16);
I have changed atol() calls to str2uint().
Unfortunately, ipmitool/helper.h does not provide appropriate API to replace
strtol(). In the code strtol() is called with radix=16 that means the input
is read in hexadecimal form only. I think it is best to leave the strtol()
calls there as they are.
I see. Well, this sucks. Two solutions come to my mind. The first is
to extend str2*() calls which, I admit, is going to be a bit of work.
The second is to check 'errno', endptr and '#include <limits.h>'. In
other words, do what str2*() calls do.
[...]
Post by Dmitry Bazhenov
Post by Zdenek Styblik
I'm also wondering whether /dev/tty or /dev/ttyS couldn't be implied
and whether extending 'struct ipmi_intf' is really necessary. But it's
just a silly question, I guess.
I couldn't find a better solution to provide a device string to the drivers.
The implying /dev/tty(s, USB) strings in the command-line is
possible.
I'll
think through how to make it without affecting those users who get
used
to
specify the full device names.
No, you're right. Serial dev can have <whatever> name. I guess it's
fine as it's.
[...]
Post by Dmitry Bazhenov
These two functions both return a pointer to the static data. Hence, the
#ifdef guard is unnecessary.
Hmm :-S Ok. To be honest, I'm disappointed, because this means
possible memory leak which "can't" be fixed.
Thanks,
Z.
Post by Dmitry Bazhenov
I'll provide the updated patch for serial drivers and separate patch for
the
bug soon.
No more comments below.
Regards,
Dmitry
Post by Zdenek Styblik
Thanks,
Z.
Post by Dmitry Bazhenov
Please, review.
Regards,
Dmitry
Post by Dmitry Bazhenov
Hello, all,
I would like to submit a patch which adds Serial Basic and
Terminal
mode
interface drivers which utilize a direct serial connection in
order
to
interact with IPMC.
Both the patches implement single and double bridging. However,
bridging
is temporarily broken for PICMG systems due to the known bridging
issues. I'm going to update the patch as soon as these issues are
resolved.
Regards,
Dmitry
------------------------------------------------------------------------------
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities.
Easily
and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d
_______________________________________________
Ipmitool-devel mailing list
https://lists.sourceforge.net/lists/listinfo/ipmitool-devel
Zdenek Styblik
2013-05-22 08:55:51 UTC
Permalink
On Tue, May 21, 2013 at 4:18 PM, Dmitry Bazhenov <***@pigeonpoint.com> wrote:
[...]
I would like not to place excessive check there in order not to overload the
code. The surrounding context pretty much ensures that the conversion goes
smoothly without errors.
Dmitry,

I still disagree, because there is no reason why not to double check
it. I guess I'm paranoid like that. However, this was a suggestion not
condition. If you say it's sufficient, then it's sufficient.
Post by Zdenek Styblik
Is there some extra documentation necessary/required (and available)
so this can be used/implemented/supported by other parties? But I
pretty much guessed this is just shoveling IPMI packets over serial
line, am I correct?
You are correct. It's just a way to interact with IPM Controllers. I don't
think that anything more than the help string is required here.
Alright.
Good. Can you acknowledge that the patch will be submitted into the
mainline?
I don't know what exactly you meant by this question. If I'm the one
doing the commit, then yes. I have no problem to commit this into
ipmitool.

Ok, I have one more question. serial_read_line() and
serial_write_line() have assert(str). Is this on purpose? Why? Are you
aware it's going to crash the program? I'm not in favour of doing such
thing. Since both functions return int, couldn't it be possible to do
without assert()?

Thanks,
Z.
No more comments below.
Regards,
Dmitry
Post by Zdenek Styblik
Thanks,
Z.
Post by Dmitry Bazhenov
Regards,
Dmitry
On Mon, May 20, 2013 at 3:07 PM, Dmitry Bazhenov
Post by Dmitry Bazhenov
Zdenek,
I agree with the first fragment changes (probably, it is worth making "rv"
an unsigned long).
Dmitry,
it was just a quick modification to show what I meant.
Post by Dmitry Bazhenov
As for the second fragment, I suggest we remove any check at all. The
surrounding context ensures that the converted string is a 2-digit
hexadecimal (see the isxdigit(ch) check upper to the fragment).
Uh. I'd be rather safe than sorry. My $0.02 USD.
Best regards,
Z.
Post by Dmitry Bazhenov
Regards,
Dmitry
On Mon, May 20, 2013 at 2:17 PM, Dmitry Bazhenov
Post by Dmitry Bazhenov
Hello, Zdenek,
I've addressed your comments.
Post by Zdenek Styblik
I see. Well, this sucks. Two solutions come to my mind. The first is
to extend str2*() calls which, I admit, is going to be a bit of work.
The second is to check 'errno', endptr and '#include <limits.h>'. In
other words, do what str2*() calls do.
I added checks of endptr and errno after the strtol() calls. In the context
of these two calls these checks look sufficient to me. Please, review.
Regards,
Dmitry
Dmitry,
please, see changes I've made/I propose. Lines which don't
being/aren't prefixed with '+' got either changed or added. Also, some
parts of the code are missing, but since you have written it, it
shouldn't be a problem.
If you have any questions regarding changes I've made, please, ask.
+static int
+recv_response(struct ipmi_intf * intf, unsigned char *data, int len)
+{
+ char hex_rs[IPMI_SERIAL_MAX_RESPONSE * 3];
int i, j, resp_len = 0;
/* This shouldn't matter since rv isn't used further in the
code, is it? */
long int rv = 0;
unsigned long int hex_tmp = 0;
[...]
+ if (strncmp(p, "ERR ", 4) == 0) {
+ serial_write_line(intf, "\r\r\r\r");
+ sleep(1);
+ serial_flush(intf);
errno = 0;
rv = strtol(p + 4, &p, 16);
+ if ((rv && rv < 0x100 && *p == '\0')
+ || (rv == 0 && !errno)) {
+ /* The message didn't get it through. The upper
+ level will have to re-send */
+ return 0;
+ } else {
+ lprintf(LOG_ERR, "Serial response is invalid");
+ return -1;
+ }
+ }
+ /* parse the response */
+ i = 0;
+ j = 0;
+ while (*p) {
[...]
+ if (j == 2) {
+ /* parse the hex number */
+ str_hex[j] = 0;
errno = 0;
hex_tmp = strtoul(str_hex, &pp, 16);
/* I'm not 100% sure about "|| *pp != '\0' " here.
Please, test it! */
if (errno != 0 || hex_tmp > UCHAR_MAX || *pp != '\0') {
/* TODO - Handle this error */
}
data[i++] = hex_tmp;
+ if (pp == str_hex || *pp != 0) {
+ break;
+ }
+ j = 0;
+ }
[...]
Best regards,
Z.
Post by Dmitry Bazhenov
Post by Zdenek Styblik
On Mon, May 20, 2013 at 6:31 AM, Dmitry Bazhenov
[...]
Post by Dmitry Bazhenov
Post by Zdenek Styblik
+ rate = atol(p + 1);
+ rate = atol(p + 1);
+ rv = strtol(p + 4, &p, 16);
+ data[i++] = (unsigned char)
strtol(str_hex,
&pp,
16);
I have changed atol() calls to str2uint().
Unfortunately, ipmitool/helper.h does not provide appropriate API to
replace
strtol(). In the code strtol() is called with radix=16 that means
the
input
is read in hexadecimal form only. I think it is best to leave the strtol()
calls there as they are.
I see. Well, this sucks. Two solutions come to my mind. The first is
to extend str2*() calls which, I admit, is going to be a bit of work.
The second is to check 'errno', endptr and '#include <limits.h>'. In
other words, do what str2*() calls do.
[...]
Post by Dmitry Bazhenov
Post by Zdenek Styblik
I'm also wondering whether /dev/tty or /dev/ttyS couldn't be implied
and whether extending 'struct ipmi_intf' is really necessary. But it's
just a silly question, I guess.
I couldn't find a better solution to provide a device string to the
drivers.
The implying /dev/tty(s, USB) strings in the command-line is
possible.
I'll
think through how to make it without affecting those users who get
used
to
specify the full device names.
No, you're right. Serial dev can have <whatever> name. I guess it's
fine as it's.
[...]
Post by Dmitry Bazhenov
These two functions both return a pointer to the static data.
Hence,
the
#ifdef guard is unnecessary.
Hmm :-S Ok. To be honest, I'm disappointed, because this means
possible memory leak which "can't" be fixed.
Thanks,
Z.
Post by Dmitry Bazhenov
I'll provide the updated patch for serial drivers and separate
patch
for
the
bug soon.
No more comments below.
Regards,
Dmitry
Post by Zdenek Styblik
Thanks,
Z.
Post by Dmitry Bazhenov
Please, review.
Regards,
Dmitry
Post by Dmitry Bazhenov
Hello, all,
I would like to submit a patch which adds Serial Basic and
Terminal
mode
interface drivers which utilize a direct serial connection in
order
to
interact with IPMC.
Both the patches implement single and double bridging. However,
bridging
is temporarily broken for PICMG systems due to the known bridging
issues. I'm going to update the patch as soon as these issues are
resolved.
Regards,
Dmitry
------------------------------------------------------------------------------
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities.
Easily
and
efficiently configure, manage, and operate all of your security
controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d
_______________________________________________
Ipmitool-devel mailing list
https://lists.sourceforge.net/lists/listinfo/ipmitool-devel
Dmitry Bazhenov
2013-05-24 07:14:10 UTC
Permalink
Hello, Zdenek,

I'll provide the updated patch in a minute with your comments addressed.
I'll add the double check you're talking about and remove the assert
since they are redundant.

Regards,
Dmitry
Post by Zdenek Styblik
[...]
I would like not to place excessive check there in order not to overload the
code. The surrounding context pretty much ensures that the conversion goes
smoothly without errors.
Dmitry,
I still disagree, because there is no reason why not to double check
it. I guess I'm paranoid like that. However, this was a suggestion not
condition. If you say it's sufficient, then it's sufficient.
Post by Zdenek Styblik
Is there some extra documentation necessary/required (and available)
so this can be used/implemented/supported by other parties? But I
pretty much guessed this is just shoveling IPMI packets over serial
line, am I correct?
You are correct. It's just a way to interact with IPM Controllers. I don't
think that anything more than the help string is required here.
Alright.
Good. Can you acknowledge that the patch will be submitted into the
mainline?
I don't know what exactly you meant by this question. If I'm the one
doing the commit, then yes. I have no problem to commit this into
ipmitool.
Ok, I have one more question. serial_read_line() and
serial_write_line() have assert(str). Is this on purpose? Why? Are you
aware it's going to crash the program? I'm not in favour of doing such
thing. Since both functions return int, couldn't it be possible to do
without assert()?
Thanks,
Z.
No more comments below.
Regards,
Dmitry
Post by Zdenek Styblik
Thanks,
Z.
Post by Dmitry Bazhenov
Regards,
Dmitry
On Mon, May 20, 2013 at 3:07 PM, Dmitry Bazhenov
Post by Dmitry Bazhenov
Zdenek,
I agree with the first fragment changes (probably, it is worth making "rv"
an unsigned long).
Dmitry,
it was just a quick modification to show what I meant.
Post by Dmitry Bazhenov
As for the second fragment, I suggest we remove any check at all. The
surrounding context ensures that the converted string is a 2-digit
hexadecimal (see the isxdigit(ch) check upper to the fragment).
Uh. I'd be rather safe than sorry. My $0.02 USD.
Best regards,
Z.
Post by Dmitry Bazhenov
Regards,
Dmitry
On Mon, May 20, 2013 at 2:17 PM, Dmitry Bazhenov
Post by Dmitry Bazhenov
Hello, Zdenek,
I've addressed your comments.
Post by Zdenek Styblik
I see. Well, this sucks. Two solutions come to my mind. The first is
to extend str2*() calls which, I admit, is going to be a bit of work.
The second is to check 'errno', endptr and '#include <limits.h>'. In
other words, do what str2*() calls do.
I added checks of endptr and errno after the strtol() calls. In the context
of these two calls these checks look sufficient to me. Please, review.
Regards,
Dmitry
Dmitry,
please, see changes I've made/I propose. Lines which don't
being/aren't prefixed with '+' got either changed or added. Also, some
parts of the code are missing, but since you have written it, it
shouldn't be a problem.
If you have any questions regarding changes I've made, please, ask.
+static int
+recv_response(struct ipmi_intf * intf, unsigned char *data, int len)
+{
+ char hex_rs[IPMI_SERIAL_MAX_RESPONSE * 3];
int i, j, resp_len = 0;
/* This shouldn't matter since rv isn't used further in the
code, is it? */
long int rv = 0;
unsigned long int hex_tmp = 0;
[...]
+ if (strncmp(p, "ERR ", 4) == 0) {
+ serial_write_line(intf, "\r\r\r\r");
+ sleep(1);
+ serial_flush(intf);
errno = 0;
rv = strtol(p + 4, &p, 16);
+ if ((rv && rv < 0x100 && *p == '\0')
+ || (rv == 0 && !errno)) {
+ /* The message didn't get it through. The upper
+ level will have to re-send */
+ return 0;
+ } else {
+ lprintf(LOG_ERR, "Serial response is invalid");
+ return -1;
+ }
+ }
+ /* parse the response */
+ i = 0;
+ j = 0;
+ while (*p) {
[...]
+ if (j == 2) {
+ /* parse the hex number */
+ str_hex[j] = 0;
errno = 0;
hex_tmp = strtoul(str_hex, &pp, 16);
/* I'm not 100% sure about "|| *pp != '\0' " here.
Please, test it! */
if (errno != 0 || hex_tmp > UCHAR_MAX || *pp != '\0') {
/* TODO - Handle this error */
}
data[i++] = hex_tmp;
+ if (pp == str_hex || *pp != 0) {
+ break;
+ }
+ j = 0;
+ }
[...]
Best regards,
Z.
Post by Dmitry Bazhenov
Post by Zdenek Styblik
On Mon, May 20, 2013 at 6:31 AM, Dmitry Bazhenov
[...]
Post by Dmitry Bazhenov
Post by Zdenek Styblik
+ rate = atol(p + 1);
+ rate = atol(p + 1);
+ rv = strtol(p + 4, &p, 16);
+ data[i++] = (unsigned char)
strtol(str_hex,
&pp,
16);
I have changed atol() calls to str2uint().
Unfortunately, ipmitool/helper.h does not provide appropriate API to
replace
strtol(). In the code strtol() is called with radix=16 that means
the
input
is read in hexadecimal form only. I think it is best to leave the
strtol()
calls there as they are.
I see. Well, this sucks. Two solutions come to my mind. The first is
to extend str2*() calls which, I admit, is going to be a bit of work.
The second is to check 'errno', endptr and '#include <limits.h>'. In
other words, do what str2*() calls do.
[...]
Post by Dmitry Bazhenov
Post by Zdenek Styblik
I'm also wondering whether /dev/tty or /dev/ttyS couldn't be implied
and whether extending 'struct ipmi_intf' is really necessary. But it's
just a silly question, I guess.
I couldn't find a better solution to provide a device string to the
drivers.
The implying /dev/tty(s, USB) strings in the command-line is
possible.
I'll
think through how to make it without affecting those users who get
used
to
specify the full device names.
No, you're right. Serial dev can have <whatever> name. I guess it's
fine as it's.
[...]
Post by Dmitry Bazhenov
These two functions both return a pointer to the static data.
Hence,
the
#ifdef guard is unnecessary.
Hmm :-S Ok. To be honest, I'm disappointed, because this means
possible memory leak which "can't" be fixed.
Thanks,
Z.
Post by Dmitry Bazhenov
I'll provide the updated patch for serial drivers and separate
patch
for
the
bug soon.
No more comments below.
Regards,
Dmitry
Post by Zdenek Styblik
Thanks,
Z.
Post by Dmitry Bazhenov
Please, review.
Regards,
Dmitry
Post by Dmitry Bazhenov
Hello, all,
I would like to submit a patch which adds Serial Basic and
Terminal
mode
interface drivers which utilize a direct serial connection in
order
to
interact with IPMC.
Both the patches implement single and double bridging. However,
bridging
is temporarily broken for PICMG systems due to the known bridging
issues. I'm going to update the patch as soon as these issues are
resolved.
Regards,
Dmitry
------------------------------------------------------------------------------
AlienVault Unified Security Management (USM) platform delivers
complete
security visibility with the essential security capabilities.
Easily
and
efficiently configure, manage, and operate all of your security
controls
from a single console and one unified framework. Download a free
trial.
http://p.sf.net/sfu/alienvault_d2d
_______________________________________________
Ipmitool-devel mailing list
https://lists.sourceforge.net/lists/listinfo/ipmitool-devel
Dmitry Bazhenov
2013-05-24 07:24:53 UTC
Permalink
Zdenek,

Here it is.

Regards,
Dmitry
Post by Dmitry Bazhenov
Hello, Zdenek,
I'll provide the updated patch in a minute with your comments addressed.
I'll add the double check you're talking about and remove the assert
since they are redundant.
Regards,
Dmitry
Post by Zdenek Styblik
On Tue, May 21, 2013 at 4:18 PM, Dmitry Bazhenov
[...]
I would like not to place excessive check there in order not to overload the
code. The surrounding context pretty much ensures that the conversion goes
smoothly without errors.
Dmitry,
I still disagree, because there is no reason why not to double check
it. I guess I'm paranoid like that. However, this was a suggestion not
condition. If you say it's sufficient, then it's sufficient.
Post by Zdenek Styblik
Is there some extra documentation necessary/required (and available)
so this can be used/implemented/supported by other parties? But I
pretty much guessed this is just shoveling IPMI packets over serial
line, am I correct?
You are correct. It's just a way to interact with IPM Controllers. I don't
think that anything more than the help string is required here.
Alright.
Good. Can you acknowledge that the patch will be submitted into the
mainline?
I don't know what exactly you meant by this question. If I'm the one
doing the commit, then yes. I have no problem to commit this into
ipmitool.
Ok, I have one more question. serial_read_line() and
serial_write_line() have assert(str). Is this on purpose? Why? Are you
aware it's going to crash the program? I'm not in favour of doing such
thing. Since both functions return int, couldn't it be possible to do
without assert()?
Thanks,
Z.
No more comments below.
Regards,
Dmitry
Post by Zdenek Styblik
Thanks,
Z.
Post by Dmitry Bazhenov
Regards,
Dmitry
On Mon, May 20, 2013 at 3:07 PM, Dmitry Bazhenov
Post by Dmitry Bazhenov
Zdenek,
I agree with the first fragment changes (probably, it is worth making
"rv"
an unsigned long).
Dmitry,
it was just a quick modification to show what I meant.
Post by Dmitry Bazhenov
As for the second fragment, I suggest we remove any check at all. The
surrounding context ensures that the converted string is a 2-digit
hexadecimal (see the isxdigit(ch) check upper to the fragment).
Uh. I'd be rather safe than sorry. My $0.02 USD.
Best regards,
Z.
Post by Dmitry Bazhenov
Regards,
Dmitry
On Mon, May 20, 2013 at 2:17 PM, Dmitry Bazhenov
Post by Dmitry Bazhenov
Hello, Zdenek,
I've addressed your comments.
Post by Zdenek Styblik
I see. Well, this sucks. Two solutions come to my mind. The first is
to extend str2*() calls which, I admit, is going to be a bit of work.
The second is to check 'errno', endptr and '#include
<limits.h>'. In
other words, do what str2*() calls do.
I added checks of endptr and errno after the strtol() calls. In the
context
of these two calls these checks look sufficient to me. Please, review.
Regards,
Dmitry
Dmitry,
please, see changes I've made/I propose. Lines which don't
being/aren't prefixed with '+' got either changed or added. Also, some
parts of the code are missing, but since you have written it, it
shouldn't be a problem.
If you have any questions regarding changes I've made, please, ask.
+static int
+recv_response(struct ipmi_intf * intf, unsigned char *data, int len)
+{
+ char hex_rs[IPMI_SERIAL_MAX_RESPONSE * 3];
int i, j, resp_len = 0;
/* This shouldn't matter since rv isn't used further in the
code, is it? */
long int rv = 0;
unsigned long int hex_tmp = 0;
[...]
+ if (strncmp(p, "ERR ", 4) == 0) {
+ serial_write_line(intf, "\r\r\r\r");
+ sleep(1);
+ serial_flush(intf);
errno = 0;
rv = strtol(p + 4, &p, 16);
+ if ((rv && rv < 0x100 && *p == '\0')
+ || (rv == 0 && !errno)) {
+ /* The message didn't get it through. The upper
+ level will have to re-send */
+ return 0;
+ } else {
+ lprintf(LOG_ERR, "Serial response is invalid");
+ return -1;
+ }
+ }
+ /* parse the response */
+ i = 0;
+ j = 0;
+ while (*p) {
[...]
+ if (j == 2) {
+ /* parse the hex number */
+ str_hex[j] = 0;
errno = 0;
hex_tmp = strtoul(str_hex, &pp, 16);
/* I'm not 100% sure about "|| *pp != '\0' " here.
Please, test it! */
if (errno != 0 || hex_tmp > UCHAR_MAX || *pp
!= '\0')
{
/* TODO - Handle this error */
}
data[i++] = hex_tmp;
+ if (pp == str_hex || *pp != 0) {
+ break;
+ }
+ j = 0;
+ }
[...]
Best regards,
Z.
Post by Dmitry Bazhenov
Post by Zdenek Styblik
On Mon, May 20, 2013 at 6:31 AM, Dmitry Bazhenov
[...]
Post by Dmitry Bazhenov
Post by Zdenek Styblik
+ rate = atol(p + 1);
+ rate = atol(p + 1);
+ rv = strtol(p + 4, &p, 16);
+ data[i++] = (unsigned char)
strtol(str_hex,
&pp,
16);
I have changed atol() calls to str2uint().
Unfortunately, ipmitool/helper.h does not provide appropriate
API
to
replace
strtol(). In the code strtol() is called with radix=16 that means
the
input
is read in hexadecimal form only. I think it is best to leave the
strtol()
calls there as they are.
I see. Well, this sucks. Two solutions come to my mind. The first is
to extend str2*() calls which, I admit, is going to be a bit of work.
The second is to check 'errno', endptr and '#include
<limits.h>'. In
other words, do what str2*() calls do.
[...]
Post by Dmitry Bazhenov
Post by Zdenek Styblik
I'm also wondering whether /dev/tty or /dev/ttyS couldn't be implied
and whether extending 'struct ipmi_intf' is really
necessary. But
it's
just a silly question, I guess.
I couldn't find a better solution to provide a device string to the
drivers.
The implying /dev/tty(s, USB) strings in the command-line is
possible.
I'll
think through how to make it without affecting those users who get
used
to
specify the full device names.
No, you're right. Serial dev can have <whatever> name. I guess it's
fine as it's.
[...]
Post by Dmitry Bazhenov
These two functions both return a pointer to the static data.
Hence,
the
#ifdef guard is unnecessary.
Hmm :-S Ok. To be honest, I'm disappointed, because this means
possible memory leak which "can't" be fixed.
Thanks,
Z.
Post by Dmitry Bazhenov
I'll provide the updated patch for serial drivers and separate
patch
for
the
bug soon.
No more comments below.
Regards,
Dmitry
Post by Zdenek Styblik
Thanks,
Z.
Post by Dmitry Bazhenov
Please, review.
Regards,
Dmitry
Post by Dmitry Bazhenov
Hello, all,
I would like to submit a patch which adds Serial Basic and
Terminal
mode
interface drivers which utilize a direct serial connection in
order
to
interact with IPMC.
Both the patches implement single and double bridging. However,
bridging
is temporarily broken for PICMG systems due to the known bridging
issues. I'm going to update the patch as soon as these issues are
resolved.
Regards,
Dmitry
------------------------------------------------------------------------------
AlienVault Unified Security Management (USM) platform delivers
complete
security visibility with the essential security capabilities.
Easily
and
efficiently configure, manage, and operate all of your security
controls
from a single console and one unified framework. Download a free
trial.
http://p.sf.net/sfu/alienvault_d2d
_______________________________________________
Ipmitool-devel mailing list
https://lists.sourceforge.net/lists/listinfo/ipmitool-devel
Zdenek Styblik
2013-05-28 04:35:17 UTC
Permalink
Post by Dmitry Bazhenov
Zdenek,
Here it is.
Regards,
Dmitry
@@ -195,6 +196,23 @@

ORIG_CPPFLAGS=$CPPFLAGS

+dnl enable serial interface
+AC_ARG_ENABLE([intf-serial],
+ [AC_HELP_STRING([--enable-intf-serial],
+ [enable direct Serial Basic/Terminal mode
interface [default=yes]])],
+ [xenable_intf_serial=$enableval], [xenable_intf_serial=yes])
+if test "x$enable_intf_serial" = "xstatic" || test
"x$enable_intf_serial" = "xplugin"; then
+ enable_intf_serial=yes
+fi
+if test "x$xenable_intf_serial" = "xyes"; then
+ AC_DEFINE(IPMI_INTF_SERIAL, [1], [Define to 1 to enable serial interface.])
+ AC_SUBST(INTF_SERIAL, [serial])
+ AC_SUBST(INTF_SERIAL_LIB, [libintf_serial.la])
+ IPMITOOL_INTF_LIB="$IPMITOOL_INTF_LIB serial/libintf_serial.la"
+else
+ xenable_intf_serial=no
+fi
+
dnl look for OpenIPMI header files
AC_ARG_WITH([kerneldir],
[AC_HELP_STRING([--with-kerneldir=DIR],
@@ -583,7 +601,8 @@

Agreed?

Z.
Post by Dmitry Bazhenov
Post by Dmitry Bazhenov
Hello, Zdenek,
I'll provide the updated patch in a minute with your comments addressed.
I'll add the double check you're talking about and remove the assert
since they are redundant.
Regards,
Dmitry
Post by Zdenek Styblik
On Tue, May 21, 2013 at 4:18 PM, Dmitry Bazhenov
[...]
I would like not to place excessive check there in order not to overload the
code. The surrounding context pretty much ensures that the conversion goes
smoothly without errors.
Dmitry,
I still disagree, because there is no reason why not to double check
it. I guess I'm paranoid like that. However, this was a suggestion not
condition. If you say it's sufficient, then it's sufficient.
Post by Zdenek Styblik
Is there some extra documentation necessary/required (and available)
so this can be used/implemented/supported by other parties? But I
pretty much guessed this is just shoveling IPMI packets over serial
line, am I correct?
You are correct. It's just a way to interact with IPM Controllers. I don't
think that anything more than the help string is required here.
Alright.
Good. Can you acknowledge that the patch will be submitted into the
mainline?
I don't know what exactly you meant by this question. If I'm the one
doing the commit, then yes. I have no problem to commit this into
ipmitool.
Ok, I have one more question. serial_read_line() and
serial_write_line() have assert(str). Is this on purpose? Why? Are you
aware it's going to crash the program? I'm not in favour of doing such
thing. Since both functions return int, couldn't it be possible to do
without assert()?
Thanks,
Z.
No more comments below.
Regards,
Dmitry
Post by Zdenek Styblik
Thanks,
Z.
Post by Dmitry Bazhenov
Regards,
Dmitry
On Mon, May 20, 2013 at 3:07 PM, Dmitry Bazhenov
Post by Dmitry Bazhenov
Zdenek,
I agree with the first fragment changes (probably, it is worth making
"rv"
an unsigned long).
Dmitry,
it was just a quick modification to show what I meant.
Post by Dmitry Bazhenov
As for the second fragment, I suggest we remove any check at all. The
surrounding context ensures that the converted string is a 2-digit
hexadecimal (see the isxdigit(ch) check upper to the fragment).
Uh. I'd be rather safe than sorry. My $0.02 USD.
Best regards,
Z.
Post by Dmitry Bazhenov
Regards,
Dmitry
On Mon, May 20, 2013 at 2:17 PM, Dmitry Bazhenov
Post by Dmitry Bazhenov
Hello, Zdenek,
I've addressed your comments.
Post by Zdenek Styblik
I see. Well, this sucks. Two solutions come to my mind. The first is
to extend str2*() calls which, I admit, is going to be a bit of work.
The second is to check 'errno', endptr and '#include
<limits.h>'. In
other words, do what str2*() calls do.
I added checks of endptr and errno after the strtol() calls. In the
context
of these two calls these checks look sufficient to me. Please, review.
Regards,
Dmitry
Dmitry,
please, see changes I've made/I propose. Lines which don't
being/aren't prefixed with '+' got either changed or added. Also, some
parts of the code are missing, but since you have written it, it
shouldn't be a problem.
If you have any questions regarding changes I've made, please, ask.
+static int
+recv_response(struct ipmi_intf * intf, unsigned char *data, int len)
+{
+ char hex_rs[IPMI_SERIAL_MAX_RESPONSE * 3];
int i, j, resp_len = 0;
/* This shouldn't matter since rv isn't used further in the
code, is it? */
long int rv = 0;
unsigned long int hex_tmp = 0;
[...]
+ if (strncmp(p, "ERR ", 4) == 0) {
+ serial_write_line(intf, "\r\r\r\r");
+ sleep(1);
+ serial_flush(intf);
errno = 0;
rv = strtol(p + 4, &p, 16);
+ if ((rv && rv < 0x100 && *p == '\0')
+ || (rv == 0 && !errno)) {
+ /* The message didn't get it through. The upper
+ level will have to re-send */
+ return 0;
+ } else {
+ lprintf(LOG_ERR, "Serial response is invalid");
+ return -1;
+ }
+ }
+ /* parse the response */
+ i = 0;
+ j = 0;
+ while (*p) {
[...]
+ if (j == 2) {
+ /* parse the hex number */
+ str_hex[j] = 0;
errno = 0;
hex_tmp = strtoul(str_hex, &pp, 16);
/* I'm not 100% sure about "|| *pp != '\0' " here.
Please, test it! */
if (errno != 0 || hex_tmp > UCHAR_MAX || *pp
!= '\0')
{
/* TODO - Handle this error */
}
data[i++] = hex_tmp;
+ if (pp == str_hex || *pp != 0) {
+ break;
+ }
+ j = 0;
+ }
[...]
Best regards,
Z.
Post by Dmitry Bazhenov
Post by Zdenek Styblik
On Mon, May 20, 2013 at 6:31 AM, Dmitry Bazhenov
[...]
Post by Dmitry Bazhenov
Post by Zdenek Styblik
+ rate = atol(p + 1);
+ rate = atol(p + 1);
+ rv = strtol(p + 4, &p, 16);
+ data[i++] = (unsigned char) strtol(str_hex,
&pp,
16);
I have changed atol() calls to str2uint().
Unfortunately, ipmitool/helper.h does not provide appropriate
API
to
replace
strtol(). In the code strtol() is called with radix=16 that means
the
input
is read in hexadecimal form only. I think it is best to leave the
strtol()
calls there as they are.
I see. Well, this sucks. Two solutions come to my mind. The first is
to extend str2*() calls which, I admit, is going to be a bit of work.
The second is to check 'errno', endptr and '#include
<limits.h>'. In
other words, do what str2*() calls do.
[...]
Post by Dmitry Bazhenov
Post by Zdenek Styblik
I'm also wondering whether /dev/tty or /dev/ttyS couldn't be
implied
and whether extending 'struct ipmi_intf' is really
necessary. But
it's
just a silly question, I guess.
I couldn't find a better solution to provide a device string to the
drivers.
The implying /dev/tty(s, USB) strings in the command-line is
possible.
I'll
think through how to make it without affecting those users who get
used
to
specify the full device names.
No, you're right. Serial dev can have <whatever> name. I guess it's
fine as it's.
[...]
Post by Dmitry Bazhenov
These two functions both return a pointer to the static data.
Hence,
the
#ifdef guard is unnecessary.
Hmm :-S Ok. To be honest, I'm disappointed, because this means
possible memory leak which "can't" be fixed.
Thanks,
Z.
Post by Dmitry Bazhenov
I'll provide the updated patch for serial drivers and separate
patch
for
the
bug soon.
No more comments below.
Regards,
Dmitry
Post by Zdenek Styblik
Thanks,
Z.
Post by Dmitry Bazhenov
Please, review.
Regards,
Dmitry
Post by Dmitry Bazhenov
Hello, all,
I would like to submit a patch which adds Serial Basic and
Terminal
mode
interface drivers which utilize a direct serial connection in
order
to
interact with IPMC.
Both the patches implement single and double bridging. However,
bridging
is temporarily broken for PICMG systems due to the known
bridging
issues. I'm going to update the patch as soon as these issues
are
resolved.
Regards,
Dmitry
------------------------------------------------------------------------------
AlienVault Unified Security Management (USM) platform delivers
complete
security visibility with the essential security capabilities.
Easily
and
efficiently configure, manage, and operate all of your security
controls
from a single console and one unified framework. Download a free
trial.
http://p.sf.net/sfu/alienvault_d2d
_______________________________________________
Ipmitool-devel mailing list
https://lists.sourceforge.net/lists/listinfo/ipmitool-devel
Dmitry Bazhenov
2013-05-28 04:39:08 UTC
Permalink
Hello, Zdenek,

There's a typo (and it's mine originally):

enable_intf_serial=yes

Needed:

xenable_intf_serial=yes

Regards,
Dmitry
Post by Zdenek Styblik
Post by Dmitry Bazhenov
Zdenek,
Here it is.
Regards,
Dmitry
@@ -195,6 +196,23 @@
ORIG_CPPFLAGS=$CPPFLAGS
+dnl enable serial interface
+AC_ARG_ENABLE([intf-serial],
+ [AC_HELP_STRING([--enable-intf-serial],
+ [enable direct Serial Basic/Terminal mode
interface [default=yes]])],
+ [xenable_intf_serial=$enableval], [xenable_intf_serial=yes])
+if test "x$enable_intf_serial" = "xstatic" || test
"x$enable_intf_serial" = "xplugin"; then
+ enable_intf_serial=yes
+fi
+if test "x$xenable_intf_serial" = "xyes"; then
+ AC_DEFINE(IPMI_INTF_SERIAL, [1], [Define to 1 to enable serial interface.])
+ AC_SUBST(INTF_SERIAL, [serial])
+ AC_SUBST(INTF_SERIAL_LIB, [libintf_serial.la])
+ IPMITOOL_INTF_LIB="$IPMITOOL_INTF_LIB serial/libintf_serial.la"
+else
+ xenable_intf_serial=no
+fi
+
dnl look for OpenIPMI header files
AC_ARG_WITH([kerneldir],
[AC_HELP_STRING([--with-kerneldir=DIR],
@@ -583,7 +601,8 @@
Agreed?
Z.
Post by Dmitry Bazhenov
Post by Dmitry Bazhenov
Hello, Zdenek,
I'll provide the updated patch in a minute with your comments addressed.
I'll add the double check you're talking about and remove the assert
since they are redundant.
Regards,
Dmitry
Post by Zdenek Styblik
On Tue, May 21, 2013 at 4:18 PM, Dmitry Bazhenov
[...]
I would like not to place excessive check there in order not to overload the
code. The surrounding context pretty much ensures that the conversion goes
smoothly without errors.
Dmitry,
I still disagree, because there is no reason why not to double check
it. I guess I'm paranoid like that. However, this was a suggestion not
condition. If you say it's sufficient, then it's sufficient.
Post by Zdenek Styblik
Is there some extra documentation necessary/required (and available)
so this can be used/implemented/supported by other parties? But I
pretty much guessed this is just shoveling IPMI packets over serial
line, am I correct?
You are correct. It's just a way to interact with IPM Controllers. I don't
think that anything more than the help string is required here.
Alright.
Good. Can you acknowledge that the patch will be submitted into the
mainline?
I don't know what exactly you meant by this question. If I'm the one
doing the commit, then yes. I have no problem to commit this into
ipmitool.
Ok, I have one more question. serial_read_line() and
serial_write_line() have assert(str). Is this on purpose? Why? Are you
aware it's going to crash the program? I'm not in favour of doing such
thing. Since both functions return int, couldn't it be possible to do
without assert()?
Thanks,
Z.
No more comments below.
Regards,
Dmitry
Post by Zdenek Styblik
Thanks,
Z.
Post by Dmitry Bazhenov
Regards,
Dmitry
On Mon, May 20, 2013 at 3:07 PM, Dmitry Bazhenov
Post by Dmitry Bazhenov
Zdenek,
I agree with the first fragment changes (probably, it is worth making
"rv"
an unsigned long).
Dmitry,
it was just a quick modification to show what I meant.
Post by Dmitry Bazhenov
As for the second fragment, I suggest we remove any check at all. The
surrounding context ensures that the converted string is a 2-digit
hexadecimal (see the isxdigit(ch) check upper to the fragment).
Uh. I'd be rather safe than sorry. My $0.02 USD.
Best regards,
Z.
Post by Dmitry Bazhenov
Regards,
Dmitry
On Mon, May 20, 2013 at 2:17 PM, Dmitry Bazhenov
Post by Dmitry Bazhenov
Hello, Zdenek,
I've addressed your comments.
Post by Zdenek Styblik
I see. Well, this sucks. Two solutions come to my mind. The first is
to extend str2*() calls which, I admit, is going to be a bit of work.
The second is to check 'errno', endptr and '#include <limits.h>'. In
other words, do what str2*() calls do.
I added checks of endptr and errno after the strtol() calls. In the
context
of these two calls these checks look sufficient to me. Please, review.
Regards,
Dmitry
Dmitry,
please, see changes I've made/I propose. Lines which don't
being/aren't prefixed with '+' got either changed or added. Also, some
parts of the code are missing, but since you have written it, it
shouldn't be a problem.
If you have any questions regarding changes I've made, please, ask.
+static int
+recv_response(struct ipmi_intf * intf, unsigned char *data, int len)
+{
+ char hex_rs[IPMI_SERIAL_MAX_RESPONSE * 3];
int i, j, resp_len = 0;
/* This shouldn't matter since rv isn't used further in the
code, is it? */
long int rv = 0;
unsigned long int hex_tmp = 0;
[...]
+ if (strncmp(p, "ERR ", 4) == 0) {
+ serial_write_line(intf, "\r\r\r\r");
+ sleep(1);
+ serial_flush(intf);
errno = 0;
rv = strtol(p + 4, &p, 16);
+ if ((rv && rv < 0x100 && *p == '\0')
+ || (rv == 0 && !errno)) {
+ /* The message didn't get it through. The upper
+ level will have to re-send */
+ return 0;
+ } else {
+ lprintf(LOG_ERR, "Serial response is invalid");
+ return -1;
+ }
+ }
+ /* parse the response */
+ i = 0;
+ j = 0;
+ while (*p) {
[...]
+ if (j == 2) {
+ /* parse the hex number */
+ str_hex[j] = 0;
errno = 0;
hex_tmp = strtoul(str_hex, &pp, 16);
/* I'm not 100% sure about "|| *pp != '\0' " here.
Please, test it! */
if (errno != 0 || hex_tmp > UCHAR_MAX || *pp
!= '\0')
{
/* TODO - Handle this error */
}
data[i++] = hex_tmp;
+ if (pp == str_hex || *pp != 0) {
+ break;
+ }
+ j = 0;
+ }
[...]
Best regards,
Z.
Post by Dmitry Bazhenov
Post by Zdenek Styblik
On Mon, May 20, 2013 at 6:31 AM, Dmitry Bazhenov
[...]
Post by Dmitry Bazhenov
Post by Zdenek Styblik
+ rate = atol(p + 1);
+ rate = atol(p + 1);
+ rv = strtol(p + 4, &p, 16);
+ data[i++] = (unsigned char)
strtol(str_hex,
&pp,
16);
I have changed atol() calls to str2uint().
Unfortunately, ipmitool/helper.h does not provide appropriate
API
to
replace
strtol(). In the code strtol() is called with radix=16 that means
the
input
is read in hexadecimal form only. I think it is best to leave the
strtol()
calls there as they are.
I see. Well, this sucks. Two solutions come to my mind. The first is
to extend str2*() calls which, I admit, is going to be a bit of work.
The second is to check 'errno', endptr and '#include <limits.h>'. In
other words, do what str2*() calls do.
[...]
Post by Dmitry Bazhenov
Post by Zdenek Styblik
I'm also wondering whether /dev/tty or /dev/ttyS couldn't be
implied
and whether extending 'struct ipmi_intf' is really
necessary. But
it's
just a silly question, I guess.
I couldn't find a better solution to provide a device string to the
drivers.
The implying /dev/tty(s, USB) strings in the command-line is
possible.
I'll
think through how to make it without affecting those users who get
used
to
specify the full device names.
No, you're right. Serial dev can have <whatever> name. I guess it's
fine as it's.
[...]
Post by Dmitry Bazhenov
These two functions both return a pointer to the static data.
Hence,
the
#ifdef guard is unnecessary.
Hmm :-S Ok. To be honest, I'm disappointed, because this means
possible memory leak which "can't" be fixed.
Thanks,
Z.
Post by Dmitry Bazhenov
I'll provide the updated patch for serial drivers and separate
patch
for
the
bug soon.
No more comments below.
Regards,
Dmitry
Post by Zdenek Styblik
Thanks,
Z.
Post by Dmitry Bazhenov
Please, review.
Regards,
Dmitry
Post by Dmitry Bazhenov
Hello, all,
I would like to submit a patch which adds Serial Basic and
Terminal
mode
interface drivers which utilize a direct serial connection in
order
to
interact with IPMC.
Both the patches implement single and double bridging.
However,
bridging
is temporarily broken for PICMG systems due to the known
bridging
issues. I'm going to update the patch as soon as these issues
are
resolved.
Regards,
Dmitry
------------------------------------------------------------------------------
AlienVault Unified Security Management (USM) platform delivers
complete
security visibility with the essential security capabilities.
Easily
and
efficiently configure, manage, and operate all of your security
controls
from a single console and one unified framework. Download a
free
trial.
http://p.sf.net/sfu/alienvault_d2d
_______________________________________________
Ipmitool-devel mailing list
https://lists.sourceforge.net/lists/listinfo/ipmitool-devel
Zdenek Styblik
2013-05-28 04:41:48 UTC
Permalink
Post by Dmitry Bazhenov
Hello, Zdenek,
enable_intf_serial=yes
xenable_intf_serial=yes
Regards,
Dmitry
Oh, I see Dmitry. However, the changes I've made seem to be required
anyway, otherwise it gets borked. Please, check again.

Thanks,
Z.
Post by Dmitry Bazhenov
Post by Zdenek Styblik
Post by Dmitry Bazhenov
Zdenek,
Here it is.
Regards,
Dmitry
@@ -195,6 +196,23 @@
ORIG_CPPFLAGS=$CPPFLAGS
+dnl enable serial interface
+AC_ARG_ENABLE([intf-serial],
+ [AC_HELP_STRING([--enable-intf-serial],
+ [enable direct Serial Basic/Terminal mode
interface [default=yes]])],
+ [xenable_intf_serial=$enableval], [xenable_intf_serial=yes])
+if test "x$enable_intf_serial" = "xstatic" || test
"x$enable_intf_serial" = "xplugin"; then
+ enable_intf_serial=yes
+fi
+if test "x$xenable_intf_serial" = "xyes"; then
+ AC_DEFINE(IPMI_INTF_SERIAL, [1], [Define to 1 to enable serial interface.])
+ AC_SUBST(INTF_SERIAL, [serial])
+ AC_SUBST(INTF_SERIAL_LIB, [libintf_serial.la])
+ IPMITOOL_INTF_LIB="$IPMITOOL_INTF_LIB serial/libintf_serial.la"
+else
+ xenable_intf_serial=no
+fi
+
dnl look for OpenIPMI header files
AC_ARG_WITH([kerneldir],
[AC_HELP_STRING([--with-kerneldir=DIR],
@@ -583,7 +601,8 @@
Agreed?
Z.
Post by Dmitry Bazhenov
Post by Dmitry Bazhenov
Hello, Zdenek,
I'll provide the updated patch in a minute with your comments addressed.
I'll add the double check you're talking about and remove the assert
since they are redundant.
Regards,
Dmitry
Post by Zdenek Styblik
On Tue, May 21, 2013 at 4:18 PM, Dmitry Bazhenov
[...]
I would like not to place excessive check there in order not to overload the
code. The surrounding context pretty much ensures that the conversion goes
smoothly without errors.
Dmitry,
I still disagree, because there is no reason why not to double check
it. I guess I'm paranoid like that. However, this was a suggestion not
condition. If you say it's sufficient, then it's sufficient.
Post by Zdenek Styblik
Is there some extra documentation necessary/required (and available)
so this can be used/implemented/supported by other parties? But I
pretty much guessed this is just shoveling IPMI packets over serial
line, am I correct?
You are correct. It's just a way to interact with IPM Controllers. I don't
think that anything more than the help string is required here.
Alright.
Good. Can you acknowledge that the patch will be submitted into the
mainline?
I don't know what exactly you meant by this question. If I'm the one
doing the commit, then yes. I have no problem to commit this into
ipmitool.
Ok, I have one more question. serial_read_line() and
serial_write_line() have assert(str). Is this on purpose? Why? Are you
aware it's going to crash the program? I'm not in favour of doing such
thing. Since both functions return int, couldn't it be possible to do
without assert()?
Thanks,
Z.
No more comments below.
Regards,
Dmitry
Post by Zdenek Styblik
Thanks,
Z.
Post by Dmitry Bazhenov
Regards,
Dmitry
On Mon, May 20, 2013 at 3:07 PM, Dmitry Bazhenov
Post by Dmitry Bazhenov
Zdenek,
I agree with the first fragment changes (probably, it is worth making
"rv"
an unsigned long).
Dmitry,
it was just a quick modification to show what I meant.
Post by Dmitry Bazhenov
As for the second fragment, I suggest we remove any check at all. The
surrounding context ensures that the converted string is a 2-digit
hexadecimal (see the isxdigit(ch) check upper to the fragment).
Uh. I'd be rather safe than sorry. My $0.02 USD.
Best regards,
Z.
Post by Dmitry Bazhenov
Regards,
Dmitry
On Mon, May 20, 2013 at 2:17 PM, Dmitry Bazhenov
Post by Dmitry Bazhenov
Hello, Zdenek,
I've addressed your comments.
Post by Zdenek Styblik
I see. Well, this sucks. Two solutions come to my mind. The
first is
to extend str2*() calls which, I admit, is going to be a bit of
work.
The second is to check 'errno', endptr and '#include
<limits.h>'. In
other words, do what str2*() calls do.
I added checks of endptr and errno after the strtol() calls. In the
context
of these two calls these checks look sufficient to me. Please,
review.
Regards,
Dmitry
Dmitry,
please, see changes I've made/I propose. Lines which don't
being/aren't prefixed with '+' got either changed or added. Also, some
parts of the code are missing, but since you have written it, it
shouldn't be a problem.
If you have any questions regarding changes I've made, please, ask.
+static int
+recv_response(struct ipmi_intf * intf, unsigned char *data, int len)
+{
+ char hex_rs[IPMI_SERIAL_MAX_RESPONSE * 3];
int i, j, resp_len = 0;
/* This shouldn't matter since rv isn't used further in the
code, is it? */
long int rv = 0;
unsigned long int hex_tmp = 0;
[...]
+ if (strncmp(p, "ERR ", 4) == 0) {
+ serial_write_line(intf, "\r\r\r\r");
+ sleep(1);
+ serial_flush(intf);
errno = 0;
rv = strtol(p + 4, &p, 16);
+ if ((rv && rv < 0x100 && *p == '\0')
+ || (rv == 0 && !errno)) {
+ /* The message didn't get it through. The upper
+ level will have to re-send */
+ return 0;
+ } else {
+ lprintf(LOG_ERR, "Serial response is invalid");
+ return -1;
+ }
+ }
+ /* parse the response */
+ i = 0;
+ j = 0;
+ while (*p) {
[...]
+ if (j == 2) {
+ /* parse the hex number */
+ str_hex[j] = 0;
errno = 0;
hex_tmp = strtoul(str_hex, &pp, 16);
/* I'm not 100% sure about "|| *pp != '\0' " here.
Please, test it! */
if (errno != 0 || hex_tmp > UCHAR_MAX || *pp
!= '\0')
{
/* TODO - Handle this error */
}
data[i++] = hex_tmp;
+ if (pp == str_hex || *pp != 0) {
+ break;
+ }
+ j = 0;
+ }
[...]
Best regards,
Z.
Post by Dmitry Bazhenov
Post by Zdenek Styblik
On Mon, May 20, 2013 at 6:31 AM, Dmitry Bazhenov
[...]
Post by Dmitry Bazhenov
Post by Zdenek Styblik
+ rate = atol(p + 1);
+ rate = atol(p + 1);
+ rv = strtol(p + 4, &p, 16);
+ data[i++] = (unsigned char)
strtol(str_hex,
&pp,
16);
I have changed atol() calls to str2uint().
Unfortunately, ipmitool/helper.h does not provide appropriate
API
to
replace
strtol(). In the code strtol() is called with radix=16 that means
the
input
is read in hexadecimal form only. I think it is best to leave the
strtol()
calls there as they are.
I see. Well, this sucks. Two solutions come to my mind. The
first is
to extend str2*() calls which, I admit, is going to be a bit of
work.
The second is to check 'errno', endptr and '#include
<limits.h>'. In
other words, do what str2*() calls do.
[...]
Post by Dmitry Bazhenov
Post by Zdenek Styblik
I'm also wondering whether /dev/tty or /dev/ttyS couldn't be
implied
and whether extending 'struct ipmi_intf' is really
necessary. But
it's
just a silly question, I guess.
I couldn't find a better solution to provide a device string
to the
drivers.
The implying /dev/tty(s, USB) strings in the command-line is
possible.
I'll
think through how to make it without affecting those users
who get
used
to
specify the full device names.
No, you're right. Serial dev can have <whatever> name. I guess it's
fine as it's.
[...]
Post by Dmitry Bazhenov
These two functions both return a pointer to the static data.
Hence,
the
#ifdef guard is unnecessary.
Hmm :-S Ok. To be honest, I'm disappointed, because this means
possible memory leak which "can't" be fixed.
Thanks,
Z.
Post by Dmitry Bazhenov
I'll provide the updated patch for serial drivers and separate
patch
for
the
bug soon.
No more comments below.
Regards,
Dmitry
Post by Zdenek Styblik
Thanks,
Z.
Post by Dmitry Bazhenov
Please, review.
Regards,
Dmitry
Post by Dmitry Bazhenov
Hello, all,
I would like to submit a patch which adds Serial Basic and
Terminal
mode
interface drivers which utilize a direct serial connection
in
order
to
interact with IPMC.
Both the patches implement single and double bridging.
However,
bridging
is temporarily broken for PICMG systems due to the known
bridging
issues. I'm going to update the patch as soon as these
issues
are
resolved.
Regards,
Dmitry
------------------------------------------------------------------------------
AlienVault Unified Security Management (USM) platform
delivers
complete
security visibility with the essential security
capabilities.
Easily
and
efficiently configure, manage, and operate all of your
security
controls
from a single console and one unified framework. Download a
free
trial.
http://p.sf.net/sfu/alienvault_d2d
_______________________________________________
Ipmitool-devel mailing list
https://lists.sourceforge.net/lists/listinfo/ipmitool-devel
Dmitry Bazhenov
2013-05-28 04:44:43 UTC
Permalink
Agreed.
Post by Zdenek Styblik
Post by Dmitry Bazhenov
Hello, Zdenek,
enable_intf_serial=yes
xenable_intf_serial=yes
Regards,
Dmitry
Oh, I see Dmitry. However, the changes I've made seem to be required
anyway, otherwise it gets borked. Please, check again.
Thanks,
Z.
Post by Dmitry Bazhenov
Post by Zdenek Styblik
Post by Dmitry Bazhenov
Zdenek,
Here it is.
Regards,
Dmitry
@@ -195,6 +196,23 @@
ORIG_CPPFLAGS=$CPPFLAGS
+dnl enable serial interface
+AC_ARG_ENABLE([intf-serial],
+ [AC_HELP_STRING([--enable-intf-serial],
+ [enable direct Serial Basic/Terminal mode
interface [default=yes]])],
+ [xenable_intf_serial=$enableval], [xenable_intf_serial=yes])
+if test "x$enable_intf_serial" = "xstatic" || test
"x$enable_intf_serial" = "xplugin"; then
+ enable_intf_serial=yes
+fi
+if test "x$xenable_intf_serial" = "xyes"; then
+ AC_DEFINE(IPMI_INTF_SERIAL, [1], [Define to 1 to enable serial interface.])
+ AC_SUBST(INTF_SERIAL, [serial])
+ AC_SUBST(INTF_SERIAL_LIB, [libintf_serial.la])
+ IPMITOOL_INTF_LIB="$IPMITOOL_INTF_LIB serial/libintf_serial.la"
+else
+ xenable_intf_serial=no
+fi
+
dnl look for OpenIPMI header files
AC_ARG_WITH([kerneldir],
[AC_HELP_STRING([--with-kerneldir=DIR],
@@ -583,7 +601,8 @@
Agreed?
Z.
Post by Dmitry Bazhenov
Post by Dmitry Bazhenov
Hello, Zdenek,
I'll provide the updated patch in a minute with your comments addressed.
I'll add the double check you're talking about and remove the assert
since they are redundant.
Regards,
Dmitry
Post by Zdenek Styblik
On Tue, May 21, 2013 at 4:18 PM, Dmitry Bazhenov
[...]
I would like not to place excessive check there in order not to overload the
code. The surrounding context pretty much ensures that the conversion goes
smoothly without errors.
Dmitry,
I still disagree, because there is no reason why not to double check
it. I guess I'm paranoid like that. However, this was a suggestion not
condition. If you say it's sufficient, then it's sufficient.
Post by Zdenek Styblik
Is there some extra documentation necessary/required (and available)
so this can be used/implemented/supported by other parties? But I
pretty much guessed this is just shoveling IPMI packets over serial
line, am I correct?
You are correct. It's just a way to interact with IPM Controllers. I don't
think that anything more than the help string is required here.
Alright.
Good. Can you acknowledge that the patch will be submitted into the
mainline?
I don't know what exactly you meant by this question. If I'm the one
doing the commit, then yes. I have no problem to commit this into
ipmitool.
Ok, I have one more question. serial_read_line() and
serial_write_line() have assert(str). Is this on purpose? Why? Are you
aware it's going to crash the program? I'm not in favour of doing such
thing. Since both functions return int, couldn't it be possible to do
without assert()?
Thanks,
Z.
No more comments below.
Regards,
Dmitry
Post by Zdenek Styblik
Thanks,
Z.
Post by Dmitry Bazhenov
Regards,
Dmitry
On Mon, May 20, 2013 at 3:07 PM, Dmitry Bazhenov
Post by Dmitry Bazhenov
Zdenek,
I agree with the first fragment changes (probably, it is worth making
"rv"
an unsigned long).
Dmitry,
it was just a quick modification to show what I meant.
Post by Dmitry Bazhenov
As for the second fragment, I suggest we remove any check at all. The
surrounding context ensures that the converted string is a 2-digit
hexadecimal (see the isxdigit(ch) check upper to the fragment).
Uh. I'd be rather safe than sorry. My $0.02 USD.
Best regards,
Z.
Post by Dmitry Bazhenov
Regards,
Dmitry
On Mon, May 20, 2013 at 2:17 PM, Dmitry Bazhenov
Post by Dmitry Bazhenov
Hello, Zdenek,
I've addressed your comments.
Post by Zdenek Styblik
I see. Well, this sucks. Two solutions come to my mind. The
first is
to extend str2*() calls which, I admit, is going to be a bit of
work.
The second is to check 'errno', endptr and '#include
<limits.h>'. In
other words, do what str2*() calls do.
I added checks of endptr and errno after the strtol() calls. In the
context
of these two calls these checks look sufficient to me. Please,
review.
Regards,
Dmitry
Dmitry,
please, see changes I've made/I propose. Lines which don't
being/aren't prefixed with '+' got either changed or added.
Also, some
parts of the code are missing, but since you have written it, it
shouldn't be a problem.
If you have any questions regarding changes I've made, please, ask.
+static int
+recv_response(struct ipmi_intf * intf, unsigned char *data, int len)
+{
+ char hex_rs[IPMI_SERIAL_MAX_RESPONSE * 3];
int i, j, resp_len = 0;
/* This shouldn't matter since rv isn't used further
in the
code, is it? */
long int rv = 0;
unsigned long int hex_tmp = 0;
[...]
+ if (strncmp(p, "ERR ", 4) == 0) {
+ serial_write_line(intf, "\r\r\r\r");
+ sleep(1);
+ serial_flush(intf);
errno = 0;
rv = strtol(p + 4, &p, 16);
+ if ((rv && rv < 0x100 && *p == '\0')
+ || (rv == 0 && !errno)) {
+ /* The message didn't get it through. The upper
+ level will have to re-send */
+ return 0;
+ } else {
+ lprintf(LOG_ERR, "Serial response is invalid");
+ return -1;
+ }
+ }
+ /* parse the response */
+ i = 0;
+ j = 0;
+ while (*p) {
[...]
+ if (j == 2) {
+ /* parse the hex number */
+ str_hex[j] = 0;
errno = 0;
hex_tmp = strtoul(str_hex, &pp, 16);
/* I'm not 100% sure about "|| *pp != '\0' "
here.
Please, test it! */
if (errno != 0 || hex_tmp > UCHAR_MAX || *pp
!= '\0')
{
/* TODO - Handle this error */
}
data[i++] = hex_tmp;
+ if (pp == str_hex || *pp != 0) {
+ break;
+ }
+ j = 0;
+ }
[...]
Best regards,
Z.
Post by Dmitry Bazhenov
Post by Zdenek Styblik
On Mon, May 20, 2013 at 6:31 AM, Dmitry Bazhenov
[...]
Post by Dmitry Bazhenov
Post by Zdenek Styblik
+ rate = atol(p + 1);
+ rate = atol(p + 1);
+ rv = strtol(p + 4, &p, 16);
+ data[i++] = (unsigned char)
strtol(str_hex,
&pp,
16);
I have changed atol() calls to str2uint().
Unfortunately, ipmitool/helper.h does not provide appropriate
API
to
replace
strtol(). In the code strtol() is called with radix=16 that
means
the
input
is read in hexadecimal form only. I think it is best to leave
the
strtol()
calls there as they are.
I see. Well, this sucks. Two solutions come to my mind. The
first is
to extend str2*() calls which, I admit, is going to be a bit of
work.
The second is to check 'errno', endptr and '#include
<limits.h>'. In
other words, do what str2*() calls do.
[...]
Post by Dmitry Bazhenov
Post by Zdenek Styblik
I'm also wondering whether /dev/tty or /dev/ttyS couldn't be
implied
and whether extending 'struct ipmi_intf' is really
necessary. But
it's
just a silly question, I guess.
I couldn't find a better solution to provide a device string
to the
drivers.
The implying /dev/tty(s, USB) strings in the command-line is
possible.
I'll
think through how to make it without affecting those users
who get
used
to
specify the full device names.
No, you're right. Serial dev can have <whatever> name. I guess
it's
fine as it's.
[...]
Post by Dmitry Bazhenov
These two functions both return a pointer to the static data.
Hence,
the
#ifdef guard is unnecessary.
Hmm :-S Ok. To be honest, I'm disappointed, because this means
possible memory leak which "can't" be fixed.
Thanks,
Z.
Post by Dmitry Bazhenov
I'll provide the updated patch for serial drivers and separate
patch
for
the
bug soon.
No more comments below.
Regards,
Dmitry
Post by Zdenek Styblik
Thanks,
Z.
Post by Dmitry Bazhenov
Please, review.
Regards,
Dmitry
Post by Dmitry Bazhenov
Hello, all,
I would like to submit a patch which adds Serial Basic and
Terminal
mode
interface drivers which utilize a direct serial connection
in
order
to
interact with IPMC.
Both the patches implement single and double bridging.
However,
bridging
is temporarily broken for PICMG systems due to the known
bridging
issues. I'm going to update the patch as soon as these
issues
are
resolved.
Regards,
Dmitry
------------------------------------------------------------------------------
AlienVault Unified Security Management (USM) platform
delivers
complete
security visibility with the essential security
capabilities.
Easily
and
efficiently configure, manage, and operate all of your
security
controls
from a single console and one unified framework. Download a
free
trial.
http://p.sf.net/sfu/alienvault_d2d
_______________________________________________
Ipmitool-devel mailing list
https://lists.sourceforge.net/lists/listinfo/ipmitool-devel
Zdenek Styblik
2013-05-28 07:48:30 UTC
Permalink
Dmitry,

I've committed your changes. However, I'm wondering about single/dual
bridging functionality. Does fixing of ID#3611226 ``bridging code
cleanup for PICMG platforms'' by Jim Mank imply it will work
auto-magically now, or is there some work left to be done to make it
work?

Thanks for clarification,
Z.

--
Zdenek Styblik
Post by Dmitry Bazhenov
Agreed.
Post by Zdenek Styblik
Post by Dmitry Bazhenov
Hello, Zdenek,
enable_intf_serial=yes
xenable_intf_serial=yes
Regards,
Dmitry
Oh, I see Dmitry. However, the changes I've made seem to be required
anyway, otherwise it gets borked. Please, check again.
Thanks,
Z.
Post by Dmitry Bazhenov
On Fri, May 24, 2013 at 9:24 AM, Dmitry Bazhenov
Post by Dmitry Bazhenov
Zdenek,
Here it is.
Regards,
Dmitry
@@ -195,6 +196,23 @@
ORIG_CPPFLAGS=$CPPFLAGS
+dnl enable serial interface
+AC_ARG_ENABLE([intf-serial],
+ [AC_HELP_STRING([--enable-intf-serial],
+ [enable direct Serial Basic/Terminal mode
interface [default=yes]])],
+ [xenable_intf_serial=$enableval], [xenable_intf_serial=yes])
+if test "x$enable_intf_serial" = "xstatic" || test
"x$enable_intf_serial" = "xplugin"; then
+ enable_intf_serial=yes
+fi
+if test "x$xenable_intf_serial" = "xyes"; then
+ AC_DEFINE(IPMI_INTF_SERIAL, [1], [Define to 1 to enable serial interface.])
+ AC_SUBST(INTF_SERIAL, [serial])
+ AC_SUBST(INTF_SERIAL_LIB, [libintf_serial.la])
+ IPMITOOL_INTF_LIB="$IPMITOOL_INTF_LIB serial/libintf_serial.la"
+else
+ xenable_intf_serial=no
+fi
+
dnl look for OpenIPMI header files
AC_ARG_WITH([kerneldir],
[AC_HELP_STRING([--with-kerneldir=DIR],
@@ -583,7 +601,8 @@
Agreed?
Z.
Post by Dmitry Bazhenov
Post by Dmitry Bazhenov
Hello, Zdenek,
I'll provide the updated patch in a minute with your comments addressed.
I'll add the double check you're talking about and remove the assert
since they are redundant.
Regards,
Dmitry
Post by Zdenek Styblik
On Tue, May 21, 2013 at 4:18 PM, Dmitry Bazhenov
[...]
I would like not to place excessive check there in order not to overload the
code. The surrounding context pretty much ensures that the
conversion
goes
smoothly without errors.
Dmitry,
I still disagree, because there is no reason why not to double check
it. I guess I'm paranoid like that. However, this was a suggestion not
condition. If you say it's sufficient, then it's sufficient.
Post by Zdenek Styblik
Is there some extra documentation necessary/required (and available)
so this can be used/implemented/supported by other parties? But I
pretty much guessed this is just shoveling IPMI packets over serial
line, am I correct?
You are correct. It's just a way to interact with IPM Controllers. I don't
think that anything more than the help string is required here.
Alright.
Good. Can you acknowledge that the patch will be submitted into the
mainline?
I don't know what exactly you meant by this question. If I'm the one
doing the commit, then yes. I have no problem to commit this into
ipmitool.
Ok, I have one more question. serial_read_line() and
serial_write_line() have assert(str). Is this on purpose? Why? Are you
aware it's going to crash the program? I'm not in favour of doing such
thing. Since both functions return int, couldn't it be possible to do
without assert()?
Thanks,
Z.
No more comments below.
Regards,
Dmitry
Post by Zdenek Styblik
Thanks,
Z.
Post by Dmitry Bazhenov
Regards,
Dmitry
On Mon, May 20, 2013 at 3:07 PM, Dmitry Bazhenov
Post by Dmitry Bazhenov
Zdenek,
I agree with the first fragment changes (probably, it is worth making
"rv"
an unsigned long).
Dmitry,
it was just a quick modification to show what I meant.
Post by Dmitry Bazhenov
As for the second fragment, I suggest we remove any check at
all.
The
surrounding context ensures that the converted string is a 2-digit
hexadecimal (see the isxdigit(ch) check upper to the fragment).
Uh. I'd be rather safe than sorry. My $0.02 USD.
Best regards,
Z.
Post by Dmitry Bazhenov
Regards,
Dmitry
On Mon, May 20, 2013 at 2:17 PM, Dmitry Bazhenov
Post by Dmitry Bazhenov
Hello, Zdenek,
I've addressed your comments.
Post by Zdenek Styblik
I see. Well, this sucks. Two solutions come to my mind. The
first is
to extend str2*() calls which, I admit, is going to be a bit of
work.
The second is to check 'errno', endptr and '#include
<limits.h>'. In
other words, do what str2*() calls do.
I added checks of endptr and errno after the strtol() calls.
In
the
context
of these two calls these checks look sufficient to me. Please,
review.
Regards,
Dmitry
Dmitry,
please, see changes I've made/I propose. Lines which don't
being/aren't prefixed with '+' got either changed or added.
Also, some
parts of the code are missing, but since you have written it, it
shouldn't be a problem.
If you have any questions regarding changes I've made, please, ask.
+static int
+recv_response(struct ipmi_intf * intf, unsigned char *data,
int
len)
+{
+ char hex_rs[IPMI_SERIAL_MAX_RESPONSE * 3];
int i, j, resp_len = 0;
/* This shouldn't matter since rv isn't used further
in the
code, is it? */
long int rv = 0;
unsigned long int hex_tmp = 0;
[...]
+ if (strncmp(p, "ERR ", 4) == 0) {
+ serial_write_line(intf, "\r\r\r\r");
+ sleep(1);
+ serial_flush(intf);
errno = 0;
rv = strtol(p + 4, &p, 16);
+ if ((rv && rv < 0x100 && *p == '\0')
+ || (rv == 0 && !errno)) {
+ /* The message didn't get it through. The upper
+ level will have to re-send */
+ return 0;
+ } else {
+ lprintf(LOG_ERR, "Serial response is invalid");
+ return -1;
+ }
+ }
+ /* parse the response */
+ i = 0;
+ j = 0;
+ while (*p) {
[...]
+ if (j == 2) {
+ /* parse the hex number */
+ str_hex[j] = 0;
errno = 0;
hex_tmp = strtoul(str_hex, &pp, 16);
/* I'm not 100% sure about "|| *pp != '\0' "
here.
Please, test it! */
if (errno != 0 || hex_tmp > UCHAR_MAX || *pp
!= '\0')
{
/* TODO - Handle this error */
}
data[i++] = hex_tmp;
+ if (pp == str_hex || *pp != 0) {
+ break;
+ }
+ j = 0;
+ }
[...]
Best regards,
Z.
Post by Dmitry Bazhenov
Post by Zdenek Styblik
On Mon, May 20, 2013 at 6:31 AM, Dmitry Bazhenov
[...]
Post by Dmitry Bazhenov
Post by Zdenek Styblik
+ rate = atol(p + 1);
+ rate = atol(p + 1);
+ rv = strtol(p + 4, &p, 16);
+ data[i++] = (unsigned char)
strtol(str_hex,
&pp,
16);
I have changed atol() calls to str2uint().
Unfortunately, ipmitool/helper.h does not provide appropriate
API
to
replace
strtol(). In the code strtol() is called with radix=16 that
means
the
input
is read in hexadecimal form only. I think it is best to leave
the
strtol()
calls there as they are.
I see. Well, this sucks. Two solutions come to my mind. The
first is
to extend str2*() calls which, I admit, is going to be a bit of
work.
The second is to check 'errno', endptr and '#include
<limits.h>'. In
other words, do what str2*() calls do.
[...]
Post by Dmitry Bazhenov
Post by Zdenek Styblik
I'm also wondering whether /dev/tty or /dev/ttyS couldn't
be
implied
and whether extending 'struct ipmi_intf' is really
necessary. But
it's
just a silly question, I guess.
I couldn't find a better solution to provide a device string
to the
drivers.
The implying /dev/tty(s, USB) strings in the command-line is
possible.
I'll
think through how to make it without affecting those users
who get
used
to
specify the full device names.
No, you're right. Serial dev can have <whatever> name. I guess
it's
fine as it's.
[...]
Post by Dmitry Bazhenov
These two functions both return a pointer to the static data.
Hence,
the
#ifdef guard is unnecessary.
Hmm :-S Ok. To be honest, I'm disappointed, because this means
possible memory leak which "can't" be fixed.
Thanks,
Z.
Post by Dmitry Bazhenov
I'll provide the updated patch for serial drivers and
separate
patch
for
the
bug soon.
No more comments below.
Regards,
Dmitry
Post by Zdenek Styblik
Thanks,
Z.
Post by Dmitry Bazhenov
Please, review.
Regards,
Dmitry
Post by Dmitry Bazhenov
Hello, all,
I would like to submit a patch which adds Serial Basic
and
Terminal
mode
interface drivers which utilize a direct serial
connection
in
order
to
interact with IPMC.
Both the patches implement single and double bridging.
However,
bridging
is temporarily broken for PICMG systems due to the known
bridging
issues. I'm going to update the patch as soon as these
issues
are
resolved.
Regards,
Dmitry
------------------------------------------------------------------------------
AlienVault Unified Security Management (USM) platform
delivers
complete
security visibility with the essential security
capabilities.
Easily
and
efficiently configure, manage, and operate all of your
security
controls
from a single console and one unified framework. Download
a
free
trial.
http://p.sf.net/sfu/alienvault_d2d
_______________________________________________
Ipmitool-devel mailing list
https://lists.sourceforge.net/lists/listinfo/ipmitool-devel
Dmitry Bazhenov
2013-05-28 08:08:58 UTC
Permalink
Zdenek,

I have updated the patch according to the Jim's changes. Nothing else to
do here.

Dmitry
Post by Zdenek Styblik
Dmitry,
I've committed your changes. However, I'm wondering about single/dual
bridging functionality. Does fixing of ID#3611226 ``bridging code
cleanup for PICMG platforms'' by Jim Mank imply it will work
auto-magically now, or is there some work left to be done to make it
work?
Thanks for clarification,
Z.
--
Zdenek Styblik
Post by Dmitry Bazhenov
Agreed.
Post by Zdenek Styblik
Post by Dmitry Bazhenov
Hello, Zdenek,
enable_intf_serial=yes
xenable_intf_serial=yes
Regards,
Dmitry
Oh, I see Dmitry. However, the changes I've made seem to be required
anyway, otherwise it gets borked. Please, check again.
Thanks,
Z.
Post by Dmitry Bazhenov
On Fri, May 24, 2013 at 9:24 AM, Dmitry Bazhenov
Post by Dmitry Bazhenov
Zdenek,
Here it is.
Regards,
Dmitry
@@ -195,6 +196,23 @@
ORIG_CPPFLAGS=$CPPFLAGS
+dnl enable serial interface
+AC_ARG_ENABLE([intf-serial],
+ [AC_HELP_STRING([--enable-intf-serial],
+ [enable direct Serial Basic/Terminal mode
interface [default=yes]])],
+ [xenable_intf_serial=$enableval], [xenable_intf_serial=yes])
+if test "x$enable_intf_serial" = "xstatic" || test
"x$enable_intf_serial" = "xplugin"; then
+ enable_intf_serial=yes
+fi
+if test "x$xenable_intf_serial" = "xyes"; then
+ AC_DEFINE(IPMI_INTF_SERIAL, [1], [Define to 1 to enable serial interface.])
+ AC_SUBST(INTF_SERIAL, [serial])
+ AC_SUBST(INTF_SERIAL_LIB, [libintf_serial.la])
+ IPMITOOL_INTF_LIB="$IPMITOOL_INTF_LIB serial/libintf_serial.la"
+else
+ xenable_intf_serial=no
+fi
+
dnl look for OpenIPMI header files
AC_ARG_WITH([kerneldir],
[AC_HELP_STRING([--with-kerneldir=DIR],
@@ -583,7 +601,8 @@
Agreed?
Z.
Post by Dmitry Bazhenov
Post by Dmitry Bazhenov
Hello, Zdenek,
I'll provide the updated patch in a minute with your comments addressed.
I'll add the double check you're talking about and remove the assert
since they are redundant.
Regards,
Dmitry
Post by Zdenek Styblik
On Tue, May 21, 2013 at 4:18 PM, Dmitry Bazhenov
[...]
Post by Dmitry Bazhenov
I would like not to place excessive check there in order not to
overload the
code. The surrounding context pretty much ensures that the
conversion
goes
smoothly without errors.
Dmitry,
I still disagree, because there is no reason why not to double check
it. I guess I'm paranoid like that. However, this was a suggestion not
condition. If you say it's sufficient, then it's sufficient.
Post by Dmitry Bazhenov
Post by Zdenek Styblik
Is there some extra documentation necessary/required (and available)
so this can be used/implemented/supported by other parties? But I
pretty much guessed this is just shoveling IPMI packets over serial
line, am I correct?
You are correct. It's just a way to interact with IPM Controllers. I don't
think that anything more than the help string is required here.
Alright.
Post by Dmitry Bazhenov
Good. Can you acknowledge that the patch will be submitted into the
mainline?
I don't know what exactly you meant by this question. If I'm the one
doing the commit, then yes. I have no problem to commit this into
ipmitool.
Ok, I have one more question. serial_read_line() and
serial_write_line() have assert(str). Is this on purpose? Why? Are you
aware it's going to crash the program? I'm not in favour of doing such
thing. Since both functions return int, couldn't it be possible to do
without assert()?
Thanks,
Z.
Post by Dmitry Bazhenov
No more comments below.
Regards,
Dmitry
Post by Zdenek Styblik
Thanks,
Z.
Post by Dmitry Bazhenov
Regards,
Dmitry
On Mon, May 20, 2013 at 3:07 PM, Dmitry Bazhenov
Post by Dmitry Bazhenov
Zdenek,
I agree with the first fragment changes (probably, it is worth
making
"rv"
an unsigned long).
Dmitry,
it was just a quick modification to show what I meant.
Post by Dmitry Bazhenov
As for the second fragment, I suggest we remove any check at
all.
The
surrounding context ensures that the converted string is a 2-digit
hexadecimal (see the isxdigit(ch) check upper to the fragment).
Uh. I'd be rather safe than sorry. My $0.02 USD.
Best regards,
Z.
Post by Dmitry Bazhenov
Regards,
Dmitry
On Mon, May 20, 2013 at 2:17 PM, Dmitry Bazhenov
Post by Dmitry Bazhenov
Hello, Zdenek,
I've addressed your comments.
Post by Zdenek Styblik
I see. Well, this sucks. Two solutions come to my mind. The
first is
to extend str2*() calls which, I admit, is going to be a bit
of
work.
The second is to check 'errno', endptr and '#include
<limits.h>'. In
other words, do what str2*() calls do.
I added checks of endptr and errno after the strtol() calls.
In
the
context
of these two calls these checks look sufficient to me. Please,
review.
Regards,
Dmitry
Dmitry,
please, see changes I've made/I propose. Lines which don't
being/aren't prefixed with '+' got either changed or added.
Also, some
parts of the code are missing, but since you have written it, it
shouldn't be a problem.
If you have any questions regarding changes I've made, please,
ask.
+static int
+recv_response(struct ipmi_intf * intf, unsigned char *data,
int
len)
+{
+ char hex_rs[IPMI_SERIAL_MAX_RESPONSE * 3];
int i, j, resp_len = 0;
/* This shouldn't matter since rv isn't used further
in the
code, is it? */
long int rv = 0;
unsigned long int hex_tmp = 0;
[...]
+ if (strncmp(p, "ERR ", 4) == 0) {
+ serial_write_line(intf, "\r\r\r\r");
+ sleep(1);
+ serial_flush(intf);
errno = 0;
rv = strtol(p + 4, &p, 16);
+ if ((rv && rv < 0x100 && *p == '\0')
+ || (rv == 0 && !errno)) {
+ /* The message didn't get it through. The upper
+ level will have to re-send */
+ return 0;
+ } else {
+ lprintf(LOG_ERR, "Serial response is invalid");
+ return -1;
+ }
+ }
+ /* parse the response */
+ i = 0;
+ j = 0;
+ while (*p) {
[...]
+ if (j == 2) {
+ /* parse the hex number */
+ str_hex[j] = 0;
errno = 0;
hex_tmp = strtoul(str_hex, &pp, 16);
/* I'm not 100% sure about "|| *pp != '\0' "
here.
Please, test it! */
if (errno != 0 || hex_tmp > UCHAR_MAX || *pp
!= '\0')
{
/* TODO - Handle this error */
}
data[i++] = hex_tmp;
+ if (pp == str_hex || *pp != 0) {
+ break;
+ }
+ j = 0;
+ }
[...]
Best regards,
Z.
Post by Dmitry Bazhenov
Post by Zdenek Styblik
On Mon, May 20, 2013 at 6:31 AM, Dmitry Bazhenov
[...]
Post by Dmitry Bazhenov
Post by Zdenek Styblik
+ rate = atol(p + 1);
+ rate = atol(p + 1);
+ rv = strtol(p + 4, &p, 16);
+ data[i++] = (unsigned char)
strtol(str_hex,
&pp,
16);
I have changed atol() calls to str2uint().
Unfortunately, ipmitool/helper.h does not provide
appropriate
API
to
replace
strtol(). In the code strtol() is called with radix=16 that
means
the
input
is read in hexadecimal form only. I think it is best to
leave
the
strtol()
calls there as they are.
I see. Well, this sucks. Two solutions come to my mind. The
first is
to extend str2*() calls which, I admit, is going to be a bit
of
work.
The second is to check 'errno', endptr and '#include
<limits.h>'. In
other words, do what str2*() calls do.
[...]
Post by Dmitry Bazhenov
Post by Zdenek Styblik
I'm also wondering whether /dev/tty or /dev/ttyS couldn't
be
implied
and whether extending 'struct ipmi_intf' is really
necessary. But
it's
just a silly question, I guess.
I couldn't find a better solution to provide a device string
to the
drivers.
The implying /dev/tty(s, USB) strings in the command-line is
possible.
I'll
think through how to make it without affecting those users
who get
used
to
specify the full device names.
No, you're right. Serial dev can have <whatever> name. I
guess
it's
fine as it's.
[...]
Post by Dmitry Bazhenov
These two functions both return a pointer to the static
data.
Hence,
the
#ifdef guard is unnecessary.
Hmm :-S Ok. To be honest, I'm disappointed, because this
means
possible memory leak which "can't" be fixed.
Thanks,
Z.
Post by Dmitry Bazhenov
I'll provide the updated patch for serial drivers and
separate
patch
for
the
bug soon.
No more comments below.
Regards,
Dmitry
Post by Zdenek Styblik
Thanks,
Z.
Post by Dmitry Bazhenov
Please, review.
Regards,
Dmitry
Post by Dmitry Bazhenov
Hello, all,
I would like to submit a patch which adds Serial Basic
and
Terminal
mode
interface drivers which utilize a direct serial
connection
in
order
to
interact with IPMC.
Both the patches implement single and double bridging.
However,
bridging
is temporarily broken for PICMG systems due to the known
bridging
issues. I'm going to update the patch as soon as these
issues
are
resolved.
Regards,
Dmitry
------------------------------------------------------------------------------
AlienVault Unified Security Management (USM) platform
delivers
complete
security visibility with the essential security
capabilities.
Easily
and
efficiently configure, manage, and operate all of your
security
controls
from a single console and one unified framework. Download
a
free
trial.
http://p.sf.net/sfu/alienvault_d2d
_______________________________________________
Ipmitool-devel mailing list
https://lists.sourceforge.net/lists/listinfo/ipmitool-devel
Dmitry Bazhenov
2013-06-17 05:05:48 UTC
Permalink
Hello, IPMITool maintainers team,

Please, review the attached patch which does the following with the code
in lib/ipmi_fru.c:

1. Removes hard-coded 16-byte length FRU inventory device transactions
and introduces a command-line argument to setup such restriction for
appropriate devices.
2. Fixes a bug where the algorithm incorrectly gathers FRU info blocks
which led to an impossibility to write data into a FRU device.
3. Adds several code optimizations by organizing FRU blocks into a
linked list which is simpler to handle in a higher layer code.
4. Replace absolute offset with the relative one which is used to access
the data buffer in the read_fru_area() API. Updated the dumping
functions correspondingly.

Regards,
Dmitry
Zdenek Styblik
2013-06-24 07:41:17 UTC
Permalink
Post by Dmitry Bazhenov
Hello, IPMITool maintainers team,
Please, review the attached patch which does the following with the code in
1. Removes hard-coded 16-byte length FRU inventory device transactions and
introduces a command-line argument to setup such restriction for appropriate
devices.
2. Fixes a bug where the algorithm incorrectly gathers FRU info blocks which
led to an impossibility to write data into a FRU device.
3. Adds several code optimizations by organizing FRU blocks into a linked
list which is simpler to handle in a higher layer code.
4. Replace absolute offset with the relative one which is used to access the
data buffer in the read_fru_area() API. Updated the dumping functions
correspondingly.
Regards,
Dmitry
Hello Dmitry,

I've read through your diffs and my comments follow. I can only review
code itself as I'm not aware of any FRU standards(nor I have looked
hard enough for it).

I'm mostly nit-picking - it looks ok in general, although I intend to
apply the diff and see "the bigger picture".

1] ``const char *section_id[4]'' - is there no chance at all this is
going to be extended at some point in future? If it is, I'd be for
better solution. My point is ``for (i = 0; i < 4; i++)'' and if it
gets extended so must code which follows/is using/iterate over it. But
may be I'm wrong.

2] lprintf() doesn't need '\n' unlike printf()

3] some code formatting issues I've seen: ``sizeof (...)'', ``if (
condition)'', ``(char *) var'' ;; these are just examples and they're
even inconsistent with your changes. I can fix these before commit
eventually.

4] it seems to me some lines are way over 80 chars in length

My $0.02 USD.

Regards,
Z.
Post by Dmitry Bazhenov
------------------------------------------------------------------------------
Build for Windows Store.
http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
Ipmitool-devel mailing list
https://lists.sourceforge.net/lists/listinfo/ipmitool-devel
Dmitry Bazhenov
2013-06-27 16:06:45 UTC
Permalink
Hello, Zdenek,

Please, see my comments below
Post by Zdenek Styblik
Post by Dmitry Bazhenov
Hello, IPMITool maintainers team,
Please, review the attached patch which does the following with the code in
1. Removes hard-coded 16-byte length FRU inventory device transactions and
introduces a command-line argument to setup such restriction for appropriate
devices.
2. Fixes a bug where the algorithm incorrectly gathers FRU info blocks which
led to an impossibility to write data into a FRU device.
3. Adds several code optimizations by organizing FRU blocks into a linked
list which is simpler to handle in a higher layer code.
4. Replace absolute offset with the relative one which is used to access the
data buffer in the read_fru_area() API. Updated the dumping functions
correspondingly.
Regards,
Dmitry
Hello Dmitry,
I've read through your diffs and my comments follow. I can only review
code itself as I'm not aware of any FRU standards(nor I have looked
hard enough for it).
I'm mostly nit-picking - it looks ok in general, although I intend to
apply the diff and see "the bigger picture".
1] ``const char *section_id[4]'' - is there no chance at all this is
going to be extended at some point in future? If it is, I'd be for
better solution. My point is ``for (i = 0; i < 4; i++)'' and if it
gets extended so must code which follows/is using/iterate over it. But
may be I'm wrong.
Is 'for ( i = 0; i < sizeof(section_id) / siceof(section_id[0]); i++)'
solves the issue?
Post by Zdenek Styblik
2] lprintf() doesn't need '\n' unlike printf()
Ok.
Post by Zdenek Styblik
3] some code formatting issues I've seen: ``sizeof (...)'', ``if (
condition)'', ``(char *) var'' ;; these are just examples and they're
even inconsistent with your changes. I can fix these before commit
eventually.
Ok.
Post by Zdenek Styblik
4] it seems to me some lines are way over 80 chars in length
Ok.

Will come up with the addressed patch shortly.

Regards,
Dmitry
Post by Zdenek Styblik
My $0.02 USD.
Regards,
Z.
Post by Dmitry Bazhenov
------------------------------------------------------------------------------
Build for Windows Store.
http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
Ipmitool-devel mailing list
https://lists.sourceforge.net/lists/listinfo/ipmitool-devel
Zdenek Styblik
2013-06-28 12:51:33 UTC
Permalink
On Thu, Jun 27, 2013 at 6:06 PM, Dmitry Bazhenov <***@pigeonpoint.com> wrote:
[...]
Post by Dmitry Bazhenov
Post by Zdenek Styblik
1] ``const char *section_id[4]'' - is there no chance at all this is
going to be extended at some point in future? If it is, I'd be for
better solution. My point is ``for (i = 0; i < 4; i++)'' and if it
gets extended so must code which follows/is using/iterate over it. But
may be I'm wrong.
Is 'for ( i = 0; i < sizeof(section_id) / siceof(section_id[0]); i++)'
solves the issue?
Dmitry,

I'm not sure if there was an issue to begin with. But to be honest,
this one looks scary. Please, let me think about it a bit, try
something; I'll try to come up with some constructive(= better?). If I
can't think of anything better, I guess, I shouldn't ask you to. I
mean, I don't know. I'll think about it, try stuff, we'll see, ok? :)

Have a nice weekend,
Z.
Dmitry Bazhenov
2013-07-02 08:41:20 UTC
Permalink
Hello, Zdenek,

The FRU information sections are hardly a subject for change in the near
future. So, I guess we can skip this issue.

I updated the formatting of the patch according to your comments and
removed the restricted FRU info access entirely since the implemented
algorithm reduces the read/write size while it is not accepted.

Please, review.

Regards,
Dmitry
Post by Zdenek Styblik
[...]
Post by Dmitry Bazhenov
Post by Zdenek Styblik
1] ``const char *section_id[4]'' - is there no chance at all this is
going to be extended at some point in future? If it is, I'd be for
better solution. My point is ``for (i = 0; i < 4; i++)'' and if it
gets extended so must code which follows/is using/iterate over it. But
may be I'm wrong.
Is 'for ( i = 0; i < sizeof(section_id) / siceof(section_id[0]); i++)'
solves the issue?
Dmitry,
I'm not sure if there was an issue to begin with. But to be honest,
this one looks scary. Please, let me think about it a bit, try
something; I'll try to come up with some constructive(= better?). If I
can't think of anything better, I guess, I shouldn't ask you to. I
mean, I don't know. I'll think about it, try stuff, we'll see, ok? :)
Have a nice weekend,
Z.
Zdenek Styblik
2013-07-04 07:39:43 UTC
Permalink
Post by Dmitry Bazhenov
Hello, Zdenek,
The FRU information sections are hardly a subject for change in the near
future. So, I guess we can skip this issue.
I updated the formatting of the patch according to your comments and removed
the restricted FRU info access entirely since the implemented algorithm
reduces the read/write size while it is not accepted.
Please, review.
Regards,
Dmitry
Alright Dmitry, I agree. Mostly because I don't have time to play
around with it right now.

I'll give a diff look sooner or later(say in a week max).

Regards,
Z.
Post by Dmitry Bazhenov
Post by Zdenek Styblik
[...]
Post by Dmitry Bazhenov
Post by Zdenek Styblik
1] ``const char *section_id[4]'' - is there no chance at all this is
going to be extended at some point in future? If it is, I'd be for
better solution. My point is ``for (i = 0; i < 4; i++)'' and if it
gets extended so must code which follows/is using/iterate over it. But
may be I'm wrong.
Is 'for ( i = 0; i < sizeof(section_id) / siceof(section_id[0]); i++)'
solves the issue?
Dmitry,
I'm not sure if there was an issue to begin with. But to be honest,
this one looks scary. Please, let me think about it a bit, try
something; I'll try to come up with some constructive(= better?). If I
can't think of anything better, I guess, I shouldn't ask you to. I
mean, I don't know. I'll think about it, try stuff, we'll see, ok? :)
Have a nice weekend,
Z.
Zdenek Styblik
2013-07-15 08:01:02 UTC
Permalink
Post by Dmitry Bazhenov
Hello, Zdenek,
The FRU information sections are hardly a subject for change in the near
future. So, I guess we can skip this issue.
I updated the formatting of the patch according to your comments and removed
the restricted FRU info access entirely since the implemented algorithm
reduces the read/write size while it is not accepted.
Please, review.
Regards,
Dmitry
[...]

Dmitry,

I've given it another look. I've added space here and there and
changed C++ style comments to C style comments. I know you've followed
style in 'lib/ipmi_fru.c', however I think error messages regarding
malloc() failure should be follow the suit of the rest of the code in
ipmitool. Again, easy to fix and somewhat minor. Hell, I'll file new
ticket for it and it will be done later.

I have the following concerns, though. In function build_fru_bloc(),
if malloc() failure occurs, you just break from the loop and that's
about it. I think this is wrong. If malloc() failure occurs, then you
either should return from the function immediately, or set variable
eg. ``error = 1; break;'' and check value of such variable once you
exit the loop.

Example:
~~~
for (i = 0; i < 4; i++) {
p_new = malloc(...);
if (p_new == NULL) {
lprintf(LOG_ERR, "out of memory");
break;
}
}
/* nothing to see, nothing just happened, moving on */
[ more code, more malloc() calls etc. ]
~~~

Seems just simply wrong. Application shouldn't continue, in my
opinion, and should terminate. No such thing happens, however, and
function proceeds over malloc() failures like nothing is going on.

fru_area_print_chassis(), fru_area_print_board(),
fru_area_print_product(), fru_area_print_multirec() - similar case.
This function returns void. malloc() failure happens and all we do is
just return from the function? Eh. It just doesn't feel right to me.

Now, I stress it's my opinion application should terminate after
malloc() failure occurs even once. The reason behind this worry is
malloc() failure may occur at given time, t_0, but it doesn't have to
occur later in t_1. Now, there is a bit of inconsistency and perhaps
some NULL pointer, isn't there? Also, more malloc() calls are stacked
up and we've been told once we won't get any memory, so why should we
try again and again? OS can be under heavy load, running short on
resources, yet we'll keep bugging about memory or what not?
However, I'm open to be explained why this isn't necessary or
eventually wrong approach in general. And ok, I can imagine cases why
this is done deliberately, but is it here? Why?

I even offer to put some code behind my words as talk is cheap. I
mean, I'm ok do to changes I've just pointed out and send a patch for
review. If there is no rush as I can't do it right now.
One more thing. If this e-mail feels offensive in any way, it's not
meant to be. So please, take it easy.

Have an easy Monday,
Z.
Post by Dmitry Bazhenov
Post by Zdenek Styblik
[...]
Post by Dmitry Bazhenov
Post by Zdenek Styblik
1] ``const char *section_id[4]'' - is there no chance at all this is
going to be extended at some point in future? If it is, I'd be for
better solution. My point is ``for (i = 0; i < 4; i++)'' and if it
gets extended so must code which follows/is using/iterate over it. But
may be I'm wrong.
Is 'for ( i = 0; i < sizeof(section_id) / siceof(section_id[0]); i++)'
solves the issue?
Dmitry,
I'm not sure if there was an issue to begin with. But to be honest,
this one looks scary. Please, let me think about it a bit, try
something; I'll try to come up with some constructive(= better?). If I
can't think of anything better, I guess, I shouldn't ask you to. I
mean, I don't know. I'll think about it, try stuff, we'll see, ok? :)
Have a nice weekend,
Z.
Dmitry Bazhenov
2013-07-15 08:50:37 UTC
Permalink
Hello, Zdenek,

Thanks for review.
I see your point and I think it make sense. I am going to address your
comments regarding the build_fru_bloc() function since this one was
under my heavy changes. I will also look at the other functions
(fru_area_print_chassis(), fru_area_print_board(),
fru_area_print_product(), fru_area_print_multirec()), but I think they
are of different case since they are just dumping functions. And in my
opinion it is not of big deal to skip through some memory allocation
failures. However, if it leads to dereference of NULL, then it is
important to add some safety checks there.

Will such a plan work for you?

Regards,
Dmitry
Post by Zdenek Styblik
Post by Dmitry Bazhenov
Hello, Zdenek,
The FRU information sections are hardly a subject for change in the near
future. So, I guess we can skip this issue.
I updated the formatting of the patch according to your comments and removed
the restricted FRU info access entirely since the implemented algorithm
reduces the read/write size while it is not accepted.
Please, review.
Regards,
Dmitry
[...]
Dmitry,
I've given it another look. I've added space here and there and
changed C++ style comments to C style comments. I know you've followed
style in 'lib/ipmi_fru.c', however I think error messages regarding
malloc() failure should be follow the suit of the rest of the code in
ipmitool. Again, easy to fix and somewhat minor. Hell, I'll file new
ticket for it and it will be done later.
I have the following concerns, though. In function build_fru_bloc(),
if malloc() failure occurs, you just break from the loop and that's
about it. I think this is wrong. If malloc() failure occurs, then you
either should return from the function immediately, or set variable
eg. ``error = 1; break;'' and check value of such variable once you
exit the loop.
~~~
for (i = 0; i < 4; i++) {
p_new = malloc(...);
if (p_new == NULL) {
lprintf(LOG_ERR, "out of memory");
break;
}
}
/* nothing to see, nothing just happened, moving on */
[ more code, more malloc() calls etc. ]
~~~
Seems just simply wrong. Application shouldn't continue, in my
opinion, and should terminate. No such thing happens, however, and
function proceeds over malloc() failures like nothing is going on.
fru_area_print_chassis(), fru_area_print_board(),
fru_area_print_product(), fru_area_print_multirec() - similar case.
This function returns void. malloc() failure happens and all we do is
just return from the function? Eh. It just doesn't feel right to me.
Now, I stress it's my opinion application should terminate after
malloc() failure occurs even once. The reason behind this worry is
malloc() failure may occur at given time, t_0, but it doesn't have to
occur later in t_1. Now, there is a bit of inconsistency and perhaps
some NULL pointer, isn't there? Also, more malloc() calls are stacked
up and we've been told once we won't get any memory, so why should we
try again and again? OS can be under heavy load, running short on
resources, yet we'll keep bugging about memory or what not?
However, I'm open to be explained why this isn't necessary or
eventually wrong approach in general. And ok, I can imagine cases why
this is done deliberately, but is it here? Why?
I even offer to put some code behind my words as talk is cheap. I
mean, I'm ok do to changes I've just pointed out and send a patch for
review. If there is no rush as I can't do it right now.
One more thing. If this e-mail feels offensive in any way, it's not
meant to be. So please, take it easy.
Have an easy Monday,
Z.
Post by Dmitry Bazhenov
Post by Zdenek Styblik
[...]
Post by Dmitry Bazhenov
Post by Zdenek Styblik
1] ``const char *section_id[4]'' - is there no chance at all this is
going to be extended at some point in future? If it is, I'd be for
better solution. My point is ``for (i = 0; i < 4; i++)'' and if it
gets extended so must code which follows/is using/iterate over it. But
may be I'm wrong.
Is 'for ( i = 0; i < sizeof(section_id) / siceof(section_id[0]); i++)'
solves the issue?
Dmitry,
I'm not sure if there was an issue to begin with. But to be honest,
this one looks scary. Please, let me think about it a bit, try
something; I'll try to come up with some constructive(= better?). If I
can't think of anything better, I guess, I shouldn't ask you to. I
mean, I don't know. I'll think about it, try stuff, we'll see, ok? :)
Have a nice weekend,
Z.
Zdenek Styblik
2013-07-15 09:57:05 UTC
Permalink
On Mon, Jul 15, 2013 at 10:50 AM, Dmitry Bazhenov
Post by Dmitry Bazhenov
Hello, Zdenek,
Thanks for review.
I see your point and I think it make sense. I am going to address your
comments regarding the build_fru_bloc() function since this one was under my
heavy changes.
Ok, great.
Post by Dmitry Bazhenov
I will also look at the other functions
(fru_area_print_chassis(), fru_area_print_board(),
fru_area_print_product(), fru_area_print_multirec()), but I think they are
of different case since they are just dumping functions. And in my opinion
it is not of big deal to skip through some memory allocation failures.
*shrug* I somewhat knew it's coming, but I've failed to address it.
Yes, they are just dumping/printing data, but they're not much of
different than any other function. It may not matter in this
case/context, but it could matter in different one ...:

~~~
[ some code here ]
fru_area_print_chassis()
[ some more code here ]
~~~

Actually, these 4 functions in question are called in consecutive order.

Hm, how about this. I'll log tickets for those and it'll get
fixed(meaning I'll fix it) later. Now I hate myself for writing, even
thinking of, such thing.
The basic idea I have is to return int and check it. No biggie.

Z.
Post by Dmitry Bazhenov
However, if it leads to dereference of NULL, then it is important to add
some safety checks there.
Will such a plan work for you?
Regards,
Dmitry
Post by Zdenek Styblik
Post by Dmitry Bazhenov
Hello, Zdenek,
The FRU information sections are hardly a subject for change in the near
future. So, I guess we can skip this issue.
I updated the formatting of the patch according to your comments and removed
the restricted FRU info access entirely since the implemented algorithm
reduces the read/write size while it is not accepted.
Please, review.
Regards,
Dmitry
[...]
Dmitry,
I've given it another look. I've added space here and there and
changed C++ style comments to C style comments. I know you've followed
style in 'lib/ipmi_fru.c', however I think error messages regarding
malloc() failure should be follow the suit of the rest of the code in
ipmitool. Again, easy to fix and somewhat minor. Hell, I'll file new
ticket for it and it will be done later.
I have the following concerns, though. In function build_fru_bloc(),
if malloc() failure occurs, you just break from the loop and that's
about it. I think this is wrong. If malloc() failure occurs, then you
either should return from the function immediately, or set variable
eg. ``error = 1; break;'' and check value of such variable once you
exit the loop.
~~~
for (i = 0; i < 4; i++) {
p_new = malloc(...);
if (p_new == NULL) {
lprintf(LOG_ERR, "out of memory");
break;
}
}
/* nothing to see, nothing just happened, moving on */
[ more code, more malloc() calls etc. ]
~~~
Seems just simply wrong. Application shouldn't continue, in my
opinion, and should terminate. No such thing happens, however, and
function proceeds over malloc() failures like nothing is going on.
fru_area_print_chassis(), fru_area_print_board(),
fru_area_print_product(), fru_area_print_multirec() - similar case.
This function returns void. malloc() failure happens and all we do is
just return from the function? Eh. It just doesn't feel right to me.
Now, I stress it's my opinion application should terminate after
malloc() failure occurs even once. The reason behind this worry is
malloc() failure may occur at given time, t_0, but it doesn't have to
occur later in t_1. Now, there is a bit of inconsistency and perhaps
some NULL pointer, isn't there? Also, more malloc() calls are stacked
up and we've been told once we won't get any memory, so why should we
try again and again? OS can be under heavy load, running short on
resources, yet we'll keep bugging about memory or what not?
However, I'm open to be explained why this isn't necessary or
eventually wrong approach in general. And ok, I can imagine cases why
this is done deliberately, but is it here? Why?
I even offer to put some code behind my words as talk is cheap. I
mean, I'm ok do to changes I've just pointed out and send a patch for
review. If there is no rush as I can't do it right now.
One more thing. If this e-mail feels offensive in any way, it's not
meant to be. So please, take it easy.
Have an easy Monday,
Z.
Post by Dmitry Bazhenov
Post by Zdenek Styblik
On Thu, Jun 27, 2013 at 6:06 PM, Dmitry Bazhenov
[...]
Post by Dmitry Bazhenov
Post by Zdenek Styblik
1] ``const char *section_id[4]'' - is there no chance at all this is
going to be extended at some point in future? If it is, I'd be for
better solution. My point is ``for (i = 0; i < 4; i++)'' and if it
gets extended so must code which follows/is using/iterate over it. But
may be I'm wrong.
Is 'for ( i = 0; i < sizeof(section_id) / siceof(section_id[0]); i++)'
solves the issue?
Dmitry,
I'm not sure if there was an issue to begin with. But to be honest,
this one looks scary. Please, let me think about it a bit, try
something; I'll try to come up with some constructive(= better?). If I
can't think of anything better, I guess, I shouldn't ask you to. I
mean, I don't know. I'll think about it, try stuff, we'll see, ok? :)
Have a nice weekend,
Z.
Dmitry Bazhenov
2013-07-29 06:24:05 UTC
Permalink
Hello, Zdenek,

I addressed the comment about malloc() failures in the build_fru_bloc()
function. Now it aborts the operation on any failure.

I didn't address the other malloc() failures since the spoken functions
are just dump the text.

Regards,
Dmitry
Post by Zdenek Styblik
On Mon, Jul 15, 2013 at 10:50 AM, Dmitry Bazhenov
Post by Dmitry Bazhenov
Hello, Zdenek,
Thanks for review.
I see your point and I think it make sense. I am going to address your
comments regarding the build_fru_bloc() function since this one was under my
heavy changes.
Ok, great.
Post by Dmitry Bazhenov
I will also look at the other functions
(fru_area_print_chassis(), fru_area_print_board(),
fru_area_print_product(), fru_area_print_multirec()), but I think they are
of different case since they are just dumping functions. And in my opinion
it is not of big deal to skip through some memory allocation failures.
*shrug* I somewhat knew it's coming, but I've failed to address it.
Yes, they are just dumping/printing data, but they're not much of
different than any other function. It may not matter in this
~~~
[ some code here ]
fru_area_print_chassis()
[ some more code here ]
~~~
Actually, these 4 functions in question are called in consecutive order.
Hm, how about this. I'll log tickets for those and it'll get
fixed(meaning I'll fix it) later. Now I hate myself for writing, even
thinking of, such thing.
The basic idea I have is to return int and check it. No biggie.
Z.
Post by Dmitry Bazhenov
However, if it leads to dereference of NULL, then it is important to add
some safety checks there.
Will such a plan work for you?
Regards,
Dmitry
Post by Zdenek Styblik
Post by Dmitry Bazhenov
Hello, Zdenek,
The FRU information sections are hardly a subject for change in the near
future. So, I guess we can skip this issue.
I updated the formatting of the patch according to your comments and removed
the restricted FRU info access entirely since the implemented algorithm
reduces the read/write size while it is not accepted.
Please, review.
Regards,
Dmitry
[...]
Dmitry,
I've given it another look. I've added space here and there and
changed C++ style comments to C style comments. I know you've followed
style in 'lib/ipmi_fru.c', however I think error messages regarding
malloc() failure should be follow the suit of the rest of the code in
ipmitool. Again, easy to fix and somewhat minor. Hell, I'll file new
ticket for it and it will be done later.
I have the following concerns, though. In function build_fru_bloc(),
if malloc() failure occurs, you just break from the loop and that's
about it. I think this is wrong. If malloc() failure occurs, then you
either should return from the function immediately, or set variable
eg. ``error = 1; break;'' and check value of such variable once you
exit the loop.
~~~
for (i = 0; i < 4; i++) {
p_new = malloc(...);
if (p_new == NULL) {
lprintf(LOG_ERR, "out of memory");
break;
}
}
/* nothing to see, nothing just happened, moving on */
[ more code, more malloc() calls etc. ]
~~~
Seems just simply wrong. Application shouldn't continue, in my
opinion, and should terminate. No such thing happens, however, and
function proceeds over malloc() failures like nothing is going on.
fru_area_print_chassis(), fru_area_print_board(),
fru_area_print_product(), fru_area_print_multirec() - similar case.
This function returns void. malloc() failure happens and all we do is
just return from the function? Eh. It just doesn't feel right to me.
Now, I stress it's my opinion application should terminate after
malloc() failure occurs even once. The reason behind this worry is
malloc() failure may occur at given time, t_0, but it doesn't have to
occur later in t_1. Now, there is a bit of inconsistency and perhaps
some NULL pointer, isn't there? Also, more malloc() calls are stacked
up and we've been told once we won't get any memory, so why should we
try again and again? OS can be under heavy load, running short on
resources, yet we'll keep bugging about memory or what not?
However, I'm open to be explained why this isn't necessary or
eventually wrong approach in general. And ok, I can imagine cases why
this is done deliberately, but is it here? Why?
I even offer to put some code behind my words as talk is cheap. I
mean, I'm ok do to changes I've just pointed out and send a patch for
review. If there is no rush as I can't do it right now.
One more thing. If this e-mail feels offensive in any way, it's not
meant to be. So please, take it easy.
Have an easy Monday,
Z.
Post by Dmitry Bazhenov
Post by Zdenek Styblik
On Thu, Jun 27, 2013 at 6:06 PM, Dmitry Bazhenov
[...]
Post by Dmitry Bazhenov
Post by Zdenek Styblik
1] ``const char *section_id[4]'' - is there no chance at all this is
going to be extended at some point in future? If it is, I'd be for
better solution. My point is ``for (i = 0; i < 4; i++)'' and if it
gets extended so must code which follows/is using/iterate over it. But
may be I'm wrong.
Is 'for ( i = 0; i < sizeof(section_id) / siceof(section_id[0]); i++)'
solves the issue?
Dmitry,
I'm not sure if there was an issue to begin with. But to be honest,
this one looks scary. Please, let me think about it a bit, try
something; I'll try to come up with some constructive(= better?). If I
can't think of anything better, I guess, I shouldn't ask you to. I
mean, I don't know. I'll think about it, try stuff, we'll see, ok? :)
Have a nice weekend,
Z.
Zdenek Styblik
2013-08-06 18:01:35 UTC
Permalink
Post by Dmitry Bazhenov
Hello, Zdenek,
Is there any progress on this ticket. Or there are obstacle for proceeding
with it?
Dmitry,

there is no progress on my side as I had to put ipmitool on
back-burner right now. As for obstacles, if you've addressed my
comments, then I don't know of any other obstacles - I assume I'd not
have any more comments.
I'll try to give your updated patch at least a look. If I see
something, I'll most likely scream.

However, I mean to log ticket for those malloc() calls in those ``just
dumping text'' functions. But as I said previously, that's not your
problem.

Regards,
Z.
Post by Dmitry Bazhenov
Regards,
Dmitry
Post by Dmitry Bazhenov
Hello, Zdenek,
I addressed the comment about malloc() failures in the build_fru_bloc()
function. Now it aborts the operation on any failure.
I didn't address the other malloc() failures since the spoken functions
are just dump the text.
Regards,
Dmitry
Post by Zdenek Styblik
On Mon, Jul 15, 2013 at 10:50 AM, Dmitry Bazhenov
Post by Dmitry Bazhenov
Hello, Zdenek,
Thanks for review.
I see your point and I think it make sense. I am going to address your
comments regarding the build_fru_bloc() function since this one was under my
heavy changes.
Ok, great.
Post by Dmitry Bazhenov
I will also look at the other functions
(fru_area_print_chassis(), fru_area_print_board(),
fru_area_print_product(), fru_area_print_multirec()), but I think they are
of different case since they are just dumping functions. And in my opinion
it is not of big deal to skip through some memory allocation failures.
*shrug* I somewhat knew it's coming, but I've failed to address it.
Yes, they are just dumping/printing data, but they're not much of
different than any other function. It may not matter in this
~~~
[ some code here ]
fru_area_print_chassis()
[ some more code here ]
~~~
Actually, these 4 functions in question are called in consecutive order.
Hm, how about this. I'll log tickets for those and it'll get
fixed(meaning I'll fix it) later. Now I hate myself for writing, even
thinking of, such thing.
The basic idea I have is to return int and check it. No biggie.
Z.
Post by Dmitry Bazhenov
However, if it leads to dereference of NULL, then it is important to add
some safety checks there.
Will such a plan work for you?
Regards,
Dmitry
On Thu, Jul 4, 2013 at 9:39 AM, Zdenek Styblik
On Tue, Jul 2, 2013 at 10:41 AM, Dmitry Bazhenov
Post by Dmitry Bazhenov
Hello, Zdenek,
The FRU information sections are hardly a subject for change in the near
future. So, I guess we can skip this issue.
I updated the formatting of the patch according to your comments and removed
the restricted FRU info access entirely since the implemented algorithm
reduces the read/write size while it is not accepted.
Please, review.
Regards,
Dmitry
[...]
Dmitry,
I've given it another look. I've added space here and there and
changed C++ style comments to C style comments. I know you've followed
style in 'lib/ipmi_fru.c', however I think error messages regarding
malloc() failure should be follow the suit of the rest of the code in
ipmitool. Again, easy to fix and somewhat minor. Hell, I'll file new
ticket for it and it will be done later.
I have the following concerns, though. In function build_fru_bloc(),
if malloc() failure occurs, you just break from the loop and that's
about it. I think this is wrong. If malloc() failure occurs, then you
either should return from the function immediately, or set variable
eg. ``error = 1; break;'' and check value of such variable once you
exit the loop.
~~~
for (i = 0; i < 4; i++) {
p_new = malloc(...);
if (p_new == NULL) {
lprintf(LOG_ERR, "out of memory");
break;
}
}
/* nothing to see, nothing just happened, moving on */
[ more code, more malloc() calls etc. ]
~~~
Seems just simply wrong. Application shouldn't continue, in my
opinion, and should terminate. No such thing happens, however, and
function proceeds over malloc() failures like nothing is going on.
fru_area_print_chassis(), fru_area_print_board(),
fru_area_print_product(), fru_area_print_multirec() - similar case.
This function returns void. malloc() failure happens and all we do is
just return from the function? Eh. It just doesn't feel right to me.
Now, I stress it's my opinion application should terminate after
malloc() failure occurs even once. The reason behind this worry is
malloc() failure may occur at given time, t_0, but it doesn't have to
occur later in t_1. Now, there is a bit of inconsistency and perhaps
some NULL pointer, isn't there? Also, more malloc() calls are stacked
up and we've been told once we won't get any memory, so why should we
try again and again? OS can be under heavy load, running short on
resources, yet we'll keep bugging about memory or what not?
However, I'm open to be explained why this isn't necessary or
eventually wrong approach in general. And ok, I can imagine cases why
this is done deliberately, but is it here? Why?
I even offer to put some code behind my words as talk is cheap. I
mean, I'm ok do to changes I've just pointed out and send a patch for
review. If there is no rush as I can't do it right now.
One more thing. If this e-mail feels offensive in any way, it's not
meant to be. So please, take it easy.
Have an easy Monday,
Z.
Post by Dmitry Bazhenov
Post by Zdenek Styblik
On Thu, Jun 27, 2013 at 6:06 PM, Dmitry Bazhenov
[...]
Post by Dmitry Bazhenov
Post by Zdenek Styblik
1] ``const char *section_id[4]'' - is there no chance at all this is
going to be extended at some point in future? If it is, I'd be for
better solution. My point is ``for (i = 0; i < 4; i++)'' and if it
gets extended so must code which follows/is using/iterate over it. But
may be I'm wrong.
Is 'for ( i = 0; i < sizeof(section_id) / siceof(section_id[0]); i++)'
solves the issue?
Dmitry,
I'm not sure if there was an issue to begin with. But to be honest,
this one looks scary. Please, let me think about it a bit, try
something; I'll try to come up with some constructive(= better?). If I
can't think of anything better, I guess, I shouldn't ask you to. I
mean, I don't know. I'll think about it, try stuff, we'll see, ok? :)
Have a nice weekend,
Z.
Continue reading on narkive:
Loading...