Though older kernels report such sockets as "unconnected" via /proc/net/unix,
the newer kernels report them as "connected". The change is introduced in
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=
83301b5367a98c17ec0d76c7bc0ccdc3c7e7ad6d
This caused a failure in a test case. To avoid the failure,
this change rewrites "state=unconnected" in the lsfd's output
to "state=connected".
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
FD=3
EXPR="(FD == 3)"
+make_state_connected()
+{
+ if [ "$1" = "socketpair" ]; then
+ lsfd_make_state_connected
+ else
+ cat
+ fi
+}
+
for C in ro-regular-file pidfd socketpair; do
ts_init_subtest $C
{
${TS_CMD_LSFD} -n -o ASSOC,KNAME,NAME -p "${PID}" -Q "${EXPR}" | {
# Replace the unpredictable an inode number for the socket
# with "INODENUM".
- sed -e 's/\[[0-9]\+\]/[INODENUM]/g'
+ sed -e 's/\[[0-9]\+\]/[INODENUM]/g' | make_state_connected $C
}
echo "$C"':ASSOC,KNAME,NAME': ${PIPESTATUS[0]}
# NAME column. Let's delete the appended string before comparing.
sed -e 's/ type=stream//'
}
+
+lsfd_make_state_connected()
+{
+ # Newer kernels report the states of unix dgram sockets created by
+ # sockerpair(2) are "connected" via /proc/net/unix though Older
+ # kernels report "unconnected".
+ #
+ # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=83301b5367a98c17ec0d76c7bc0ccdc3c7e7ad6d
+ #
+ # This rewriting adjusts the output of lsfd running on older kernels
+ # to that on newer kernels.
+ sed -e 's/state=unconnected/state=connected/'
+}