Bug 1395050 - sysctl return 0 even fail to set value
Summary: sysctl return 0 even fail to set value
Keywords:
Status: CLOSED DUPLICATE of bug 1264080
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: procps-ng
Version: 7.3
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Jan Rybar
QA Contact: BaseOS QE - Apps
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-11-15 03:21 UTC by Jianlin Shi
Modified: 2016-11-29 14:28 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-11-29 14:28:05 UTC
Target Upstream Version:


Attachments (Terms of Use)

Description Jianlin Shi 2016-11-15 03:21:02 UTC
Description of problem:
sysctl return 0 even fail to set value

Version-Release number of selected component (if applicable):
procps-ng-3.3.10-10.el7.x86_64

How reproducible:
Always

Steps to Reproduce:
1. sysctl  -w net.ipv4.ip_default_ttl=0
2. check return value

Actual results:
return value is 0

Expected results:
return value should be 255

Additional info:

[root@ibm-x3650m5-03 proc_sys_net_ipv4]# uname -a
Linux ibm-x3650m5-03.rhts.eng.pek2.redhat.com 3.10.0-514.el7.x86_64 #1 SMP Wed Oct 19 11:24:13 EDT 2016 x86_64 x86_64 x86_64 GNU/Linux
[root@ibm-x3650m5-03 proc_sys_net_ipv4]# rpm -qa | grep procps
procps-ng-3.3.10-10.el7.x86_64
[root@ibm-x3650m5-03 proc_sys_net_ipv4]# sysctl  -w net.ipv4.ip_default_ttl=0
sysctl: setting key "net.ipv4.ip_default_ttl": Invalid argument
net.ipv4.ip_default_ttl = 0
[root@ibm-x3650m5-03 proc_sys_net_ipv4]# echo $?
0
[root@ibm-x3650m5-03 proc_sys_net_ipv4]# sysctl net.ipv4.ip_default_ttl
net.ipv4.ip_default_ttl = 64

Comment 1 Kamil Dudka 2016-11-15 09:16:59 UTC
(In reply to Jianlin Shi from comment #0)
> Steps to Reproduce:
> 1. sysctl  -w net.ipv4.ip_default_ttl=0
> 2. check return value
> 
> Actual results:
> return value is 0

This looks incorrect indeed.  The exit code should be non-zero if sysctl failed to write the value.

> Expected results:
> return value should be 255

Why do you think that exactly 255 should be returned?

Comment 2 Jianlin Shi 2016-11-15 09:26:50 UTC
(In reply to Kamil Dudka from comment #1)
> (In reply to Jianlin Shi from comment #0)
> > Steps to Reproduce:
> > 1. sysctl  -w net.ipv4.ip_default_ttl=0
> > 2. check return value
> > 
> > Actual results:
> > return value is 0
> 
> This looks incorrect indeed.  The exit code should be non-zero if sysctl
> failed to write the value.
> 
> > Expected results:
> > return value should be 255
> 
> Why do you think that exactly 255 should be returned?

program normally return 255 if the error is "Invalid argument". BTW, sysctl return 255 on rhel6.

Comment 3 Jan Rybar 2016-11-15 12:45:56 UTC
Issue reproduced and will be investigated.
Thank you for your report.

Comment 4 Jan Rybar 2016-11-29 14:28:05 UTC
Looks like duplicate of https://bugzilla.redhat.com/show_bug.cgi?id=1264080

Closing as DUPLICATE

*** This bug has been marked as a duplicate of bug 1264080 ***


Note You need to log in before you can comment on or make changes to this bug.