Skip to contentSkip to conversation

tools/netconsole: Add support for socat

PATCH In review Andy Shevchenko 4 participants 5 messages Nov 17, 2021 – Dec 2, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools/netconsole: Add support for socat

socat is a very powerful tool to work with socets (and not only) in UNIX systems. Let's add support for it in netconsole.

---
 tools/netconsole | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
tools/netconsole +10 -2
index 1a0ef22244e3..155453320f73 100755
@@ -34,7 +34,7 @@ if [ -z "${ip}" ] || [ -n "$4" ] ; then
 	usage "Invalid number of arguments"
 fi
 
-for nc in netcat nc ; do
+for nc in socat netcat nc ; do
 	type ${nc} >/dev/null 2>&1 && break
 done
 
@@ -47,6 +47,10 @@ if type ncb 2>/dev/null ; then
 	# see if ncb is in $PATH
 	exec ncb ${board_out_port}
 
+elif [ "${nc}" = "socat" ] ; then
+	# socat does support broadcast
+	while ${nc} STDIO "UDP4-LISTEN:${board_out_port}"; do :; done
+
 elif [ -x ${0%/*}/ncb ] ; then
 	# maybe it's in the same dir as the netconsole script
 	exec ${0%/*}/ncb ${board_out_port}
@@ -59,5 +63,9 @@ else
 fi
 ) &
 pid=$!
-${nc} -u ${ip} ${board_in_port}
+if [ "${nc}" = "socat" ] ; then
+	${nc} - "UDP4:${ip}:${board_in_port}"
+else
+	${nc} -u ${ip} ${board_in_port}
+fi
 kill ${pid} 2>/dev/null
Signature · 1 line
2.33.0
Tested-by on v1 1/1
#1 lore raw

Hi,

Op 17-11-2021 om 18:15 schreef Andy Shevchenko:

Quoted 4 lines

socat is a very powerful tool to work with socets (and not only) in UNIX systems. Let's add support for it in netconsole.

Quoted 39 lines
---
  tools/netconsole | 12 ++++++++++--
  1 file changed, 10 insertions(+), 2 deletions(-)
tools/netconsole +10 -2
index 1a0ef22244e3..155453320f73 100755
@@ -34,7 +34,7 @@ if [ -z "${ip}" ] || [ -n "$4" ] ; then
  	usage "Invalid number of arguments"
  fi
 
-for nc in netcat nc ; do
+for nc in socat netcat nc ; do
  	type ${nc} >/dev/null 2>&1 && break
  done
 
@@ -47,6 +47,10 @@ if type ncb 2>/dev/null ; then
  	# see if ncb is in $PATH
  	exec ncb ${board_out_port}
 
+elif [ "${nc}" = "socat" ] ; then
+	# socat does support broadcast
+	while ${nc} STDIO "UDP4-LISTEN:${board_out_port}"; do :; done
+
  elif [ -x ${0%/*}/ncb ] ; then
  	# maybe it's in the same dir as the netconsole script
  	exec ${0%/*}/ncb ${board_out_port}
@@ -59,5 +63,9 @@ else
  fi
  ) &
  pid=$!
-${nc} -u ${ip} ${board_in_port}
+if [ "${nc}" = "socat" ] ; then
+	${nc} - "UDP4:${ip}:${board_in_port}"
+else
+	${nc} -u ${ip} ${board_in_port}
+fi
  kill ${pid} 2>/dev/null
#2 lore raw
Quoted 9 lines · Ferry Toth

Hi,

Op 17-11-2021 om 18:15 schreef Andy Shevchenko:

Quoted 4 lines

socat is a very powerful tool to work with socets (and not only) in UNIX systems. Let's add support for it in netconsole.

Thanks!

Can thi be applied, please?

Quoted 39 lines
Quoted 39 lines
---
  tools/netconsole | 12 ++++++++++--
  1 file changed, 10 insertions(+), 2 deletions(-)
tools/netconsole +10 -2
index 1a0ef22244e3..155453320f73 100755
@@ -34,7 +34,7 @@ if [ -z "${ip}" ] || [ -n "$4" ] ; then
      usage "Invalid number of arguments"
  fi
 
-for nc in netcat nc ; do
+for nc in socat netcat nc ; do
      type ${nc} >/dev/null 2>&1 && break
  done
 
@@ -47,6 +47,10 @@ if type ncb 2>/dev/null ; then
      # see if ncb is in $PATH
      exec ncb ${board_out_port}
 
+elif [ "${nc}" = "socat" ] ; then
+     # socat does support broadcast
+     while ${nc} STDIO "UDP4-LISTEN:${board_out_port}"; do :; done
+
  elif [ -x ${0%/*}/ncb ] ; then
      # maybe it's in the same dir as the netconsole script
      exec ${0%/*}/ncb ${board_out_port}
@@ -59,5 +63,9 @@ else
  fi
  ) &
  pid=$!
-${nc} -u ${ip} ${board_in_port}
+if [ "${nc}" = "socat" ] ; then
+     ${nc} - "UDP4:${ip}:${board_in_port}"
+else
+     ${nc} -u ${ip} ${board_in_port}
+fi
  kill ${pid} 2>/dev/null
Signature · 2 lines
With Best Regards,
Andy Shevchenko
Reviewed-by
#3 lore raw
Quoted 53 lines · Andy Shevchenko
Quoted 9 lines · Ferry Toth

Hi,

Op 17-11-2021 om 18:15 schreef Andy Shevchenko:

Quoted 4 lines

socat is a very powerful tool to work with socets (and not only) in UNIX systems. Let's add support for it in netconsole.

Thanks!

Can thi be applied, please?

Quoted 37 lines
Quoted 37 lines
---
  tools/netconsole | 12 ++++++++++--
  1 file changed, 10 insertions(+), 2 deletions(-)
tools/netconsole +9 -2
index 1a0ef22244e3..155453320f73 100755
@@ -34,7 +34,7 @@ if [ -z "${ip}" ] || [ -n "$4" ] ; then
      usage "Invalid number of arguments"
  fi
 
-for nc in netcat nc ; do
+for nc in socat netcat nc ; do
      type ${nc} >/dev/null 2>&1 && break
  done
 
@@ -47,6 +47,10 @@ if type ncb 2>/dev/null ; then
      # see if ncb is in $PATH
      exec ncb ${board_out_port}
 
+elif [ "${nc}" = "socat" ] ; then
+     # socat does support broadcast
+     while ${nc} STDIO "UDP4-LISTEN:${board_out_port}"; do :; done
+
  elif [ -x ${0%/*}/ncb ] ; then
      # maybe it's in the same dir as the netconsole script
      exec ${0%/*}/ncb ${board_out_port}
@@ -59,5 +63,9 @@ else
  fi
  ) &
  pid=$!
-${nc} -u ${ip} ${board_in_port}
+if [ "${nc}" = "socat" ] ; then
+     ${nc} - "UDP4:${ip}:${board_in_port}"
+else
+     ${nc} -u ${ip} ${board_in_port}
Quoted 8 lines
Quoted 2 lines

tools/netconsole else · line 71

Quoted 2 lines
tools/netconsole +1 -0
+fi
  kill ${pid} 2>/dev/null

--
With Best Regards,
Andy Shevchenko

#4 lore raw
Quoted 64 lines · Ramon Fried
Quoted 53 lines · Andy Shevchenko
Quoted 9 lines · Ferry Toth

Hi,

Op 17-11-2021 om 18:15 schreef Andy Shevchenko:

Quoted 4 lines

socat is a very powerful tool to work with socets (and not only) in UNIX systems. Let's add support for it in netconsole.

Thanks!

Can thi be applied, please?

Quoted 37 lines
Quoted 37 lines
---
  tools/netconsole | 12 ++++++++++--
  1 file changed, 10 insertions(+), 2 deletions(-)
tools/netconsole +9 -2
index 1a0ef22244e3..155453320f73 100755
@@ -34,7 +34,7 @@ if [ -z "${ip}" ] || [ -n "$4" ] ; then
      usage "Invalid number of arguments"
  fi
 
-for nc in netcat nc ; do
+for nc in socat netcat nc ; do
      type ${nc} >/dev/null 2>&1 && break
  done
 
@@ -47,6 +47,10 @@ if type ncb 2>/dev/null ; then
      # see if ncb is in $PATH
      exec ncb ${board_out_port}
 
+elif [ "${nc}" = "socat" ] ; then
+     # socat does support broadcast
+     while ${nc} STDIO "UDP4-LISTEN:${board_out_port}"; do :; done
+
  elif [ -x ${0%/*}/ncb ] ; then
      # maybe it's in the same dir as the netconsole script
      exec ${0%/*}/ncb ${board_out_port}
@@ -59,5 +63,9 @@ else
  fi
  ) &
  pid=$!
-${nc} -u ${ip} ${board_in_port}
+if [ "${nc}" = "socat" ] ; then
+     ${nc} - "UDP4:${ip}:${board_in_port}"
+else
+     ${nc} -u ${ip} ${board_in_port}
Quoted 8 lines
Quoted 2 lines

tools/netconsole else · line 71

Quoted 2 lines
tools/netconsole +1 -0
+fi
  kill ${pid} 2>/dev/null

--
With Best Regards,
Andy Shevchenko

Quoted 1 line

Applied to u-boot-net/next,
Thanks.