diff mbox series

[net-next] selftests: Set default protocol for raw sockets in nettest

Message ID 20200917151333.41252-1-dsahern@kernel.org
State Accepted
Delegated to: David Miller
Headers show
Series [net-next] selftests: Set default protocol for raw sockets in nettest | expand

Commit Message

David Ahern Sept. 17, 2020, 3:13 p.m. UTC
IPPROTO_IP (0) is not valid for raw sockets. Default the protocol for
raw sockets to IPPROTO_RAW if the protocol has not been set via the -P
option.

Signed-off-by: David Ahern <dsahern@kernel.org>
---
 tools/testing/selftests/net/nettest.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

David Miller Sept. 18, 2020, 12:07 a.m. UTC | #1
From: David Ahern <dsahern@kernel.org>
Date: Thu, 17 Sep 2020 09:13:33 -0600

> IPPROTO_IP (0) is not valid for raw sockets. Default the protocol for
> raw sockets to IPPROTO_RAW if the protocol has not been set via the -P
> option.
> 
> Signed-off-by: David Ahern <dsahern@kernel.org>

Applied, thanks David.
diff mbox series

Patch

diff --git a/tools/testing/selftests/net/nettest.c b/tools/testing/selftests/net/nettest.c
index 93208caacbe6..f75c53ce0a2d 100644
--- a/tools/testing/selftests/net/nettest.c
+++ b/tools/testing/selftests/net/nettest.c
@@ -1667,6 +1667,8 @@  int main(int argc, char *argv[])
 		case 'R':
 			args.type = SOCK_RAW;
 			args.port = 0;
+			if (!args.protocol)
+				args.protocol = IPPROTO_RAW;
 			break;
 		case 'P':
 			pe = getprotobyname(optarg);