Skip to contentSkip to conversation

ss: move to its own directory and split up ss.c

PATCH New Stephen Hemminger 1 participant 2 messages Nov 25

Subsystems (3)
lore
Share & tools
lore
#1 lore raw

PATCH v2 2/2 ss: build the socket cookie with a single shift

In reply to Stephen Hemminger

From: Frank Dressler <[email protected]>

The split shift was necessary only while the code used unsigned long. 2e7e805d0aac ("ss: better 32bit support") changed it to unsigned long long.

---
v2 - handle post ss split up

 ss/sock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
ss/sock.c +1 -1
index ca243f18..879af555 100644
@@ -12,7 +12,7 @@
 
 unsigned long long cookie_sk_get(const uint32_t *cookie)
 {
-	return (((unsigned long long)cookie[1] << 31) << 1) | cookie[0];
+	return ((unsigned long long)cookie[1] << 32) | cookie[0];
 }
 
 static const char *unix_netid_name(int type)
Signature · 1 line
2.53.0
#0 lore raw

PATCH v2 1/2 ss: move to its own directory and split up ss.c

The ss command has grown over time and was a single large file. Move it and its filter parser to ss/ with their own Makefile, and split ss.c by function:

  ss.h        shared types, option flags and prototypes
  ss.c        main() and option parsing
  output.c    column layout and buffered output
  sock.c      output common to all socket families
  filter.c    socket selection and filter expressions
  users.c     socket owners and SELinux contexts from /proc
  service.c   port to service name resolution
  inet.c      inet_diag dumps, kill and TCPDIAG_FILE replay
  tcp.c       TCP, TLS and MPTCP details
  sctp.c      SCTP details
  bpf.c       BPF socket-local storage

unix.c, packet.c, xdp.c, netlink.c, vsock.c, tipc.c
one file per socket family
events.c -E event monitoring
summary.c -s summary

---
v2 - cleanup more leftovers
- make sure BPF parts still work

 Makefile                      |    2 +-
 misc/.gitignore               |    2 -
 misc/Makefile                 |   11 +-
 misc/ss.c                     | 6261 ---------------------------------
 ss/.gitignore                 |    2 +
 ss/Makefile                   |   21 +
 ss/bpf.c                      |  335 ++
 ss/events.c                   |   95 +
 ss/filter.c                   |  927 +++++
 ss/inet.c                     |  576 +++
 ss/netlink.c                  |  205 ++
 ss/output.c                   |  529 +++
 ss/packet.c                   |  216 ++
 ss/sctp.c                     |  140 +
 ss/service.c                  |  246 ++
 ss/sock.c                     |  276 ++
 ss/ss.c                       |  595 ++++
 ss/ss.h                       |  371 ++
 {misc => ss}/ss_util.h        |    0
 {misc => ss}/ssfilter.h       |    0
 {misc => ss}/ssfilter.y       |    0
 {misc => ss}/ssfilter_check.c |    0
 ss/summary.c                  |  167 +
 ss/tcp.c                      |  623 ++++
 ss/tipc.c                     |  119 +
 ss/unix.c                     |  140 +
 ss/users.c                    |  333 ++
 ss/vsock.c                    |   87 +
 ss/xdp.c                      |  170 +
 testsuite/Makefile            |    2 +-
 testsuite/tests/ss/ssfilter.t |    2 +-
 31 files changed, 6178 insertions(+), 6275 deletions(-)
 delete mode 100644 misc/ss.c
 create mode 100644 ss/.gitignore
 create mode 100644 ss/Makefile
 create mode 100644 ss/bpf.c
 create mode 100644 ss/events.c
 create mode 100644 ss/filter.c
 create mode 100644 ss/inet.c
 create mode 100644 ss/netlink.c
 create mode 100644 ss/output.c
 create mode 100644 ss/packet.c
 create mode 100644 ss/sctp.c
 create mode 100644 ss/service.c
 create mode 100644 ss/sock.c
 create mode 100644 ss/ss.c
 create mode 100644 ss/ss.h
 rename {misc => ss}/ss_util.h (100%)
 rename {misc => ss}/ssfilter.h (100%)
 rename {misc => ss}/ssfilter.y (100%)
 rename {misc => ss}/ssfilter_check.c (100%)
 create mode 100644 ss/summary.c
 create mode 100644 ss/tcp.c
 create mode 100644 ss/tipc.c
 create mode 100644 ss/unix.c
 create mode 100644 ss/users.c
 create mode 100644 ss/vsock.c
 create mode 100644 ss/xdp.c
Makefile +1 -1
index 6e4e6a85..d3755305 100644
@@ -55,7 +55,7 @@ WFLAGS += -Wmissing-declarations -Wold-style-definition -Wformat=2
 CFLAGS := $(WFLAGS) $(CCOPTS) -I../include -I../include/uapi $(DEFINES) $(CFLAGS)
 YACCFLAGS = -d -t -v
 
-SUBDIRS=lib ip tc bridge misc netem genl man
+SUBDIRS=lib ip tc bridge misc ss netem genl man
 ifeq ($(HAVE_MNL),y)
 SUBDIRS += tipc devlink rdma dcb vdpa netshaper dpll
 endif
misc/.gitignore +0 -2
index 1177605e..aec7666a 100644
@@ -1,6 +1,4 @@
 ifstat
-ss
-ssfilter.tab.c
 nstat
 lnstat
 rtacct
misc/Makefile +2 -9
index 4736d928..1e8f4ea9 100644
@@ -1,16 +1,12 @@
 # SPDX-License-Identifier: GPL-2.0
-SSOBJ=ss.o ssfilter_check.o ssfilter.tab.o
 LNSTATOBJ=lnstat.o lnstat_util.o
 
-TARGETS=ss nstat ifstat rtacct lnstat
+TARGETS=nstat ifstat rtacct lnstat
 
 include ../config.mk
 
 all: $(TARGETS)
 
-ss: $(SSOBJ)
-	$(QUIET_LINK)$(CC) $^ $(LDFLAGS) $(LDLIBS) -o $@
-
 nstat: nstat.c
 	$(QUIET_CC)$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o nstat nstat.c $(LDLIBS) -lm
 
@@ -20,9 +16,6 @@ ifstat: ifstat.c
 rtacct: rtacct.c
 	$(QUIET_CC)$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o rtacct rtacct.c $(LDLIBS) -lm
 
-ssfilter.tab.c: ssfilter.y
-	$(QUIET_YACC)$(YACC) -b ssfilter ssfilter.y
-
 lnstat: $(LNSTATOBJ)
 	$(QUIET_LINK)$(CC) $^ $(LDFLAGS) $(LDLIBS) -o $@
 
@@ -32,4 +25,4 @@ install: all
 	ln -sf lnstat $(DESTDIR)$(SBINDIR)/ctstat
 
 clean:
-	rm -f *.o $(TARGETS) ssfilter.c
+	rm -f *.o $(TARGETS)
misc/ss.c deleted +0 -6261

2,955 lines not on this page · raw message

ss/.gitignore new file +2 -0
new file mode 100644
index 00000000..650c3739

Lines of this file are not shown. View the raw message.

ss/Makefile new file +21 -0
new file mode 100644
index 00000000..364af87a

Lines of this file are not shown. View the raw message.

ss/bpf.c new file +335 -0

335 lines not on this page · raw message

ss/events.c new file +95 -0

95 lines not on this page · raw message

ss/filter.c new file +927 -0

927 lines not on this page · raw message

ss/inet.c new file +576 -0

576 lines not on this page · raw message

ss/netlink.c new file +205 -0

205 lines not on this page · raw message

ss/output.c new file +529 -0

529 lines not on this page · raw message

ss/packet.c new file +216 -0

216 lines not on this page · raw message

ss/sctp.c new file +140 -0

140 lines not on this page · raw message

ss/service.c new file +246 -0

246 lines not on this page · raw message

ss/sock.c new file +276 -0

276 lines not on this page · raw message

ss/ss.c new file +595 -0

595 lines not on this page · raw message

ss/ss.h new file +371 -0

371 lines not on this page · raw message

ss/ss_util.h renamed from misc/ss_util.h +0 -0
similarity index 100%
rename from misc/ss_util.h
rename to ss/ss_util.h
ss/ssfilter.h renamed from misc/ssfilter.h +0 -0
similarity index 100%
rename from misc/ssfilter.h
rename to ss/ssfilter.h
ss/ssfilter.y renamed from misc/ssfilter.y +0 -0
similarity index 100%
rename from misc/ssfilter.y
rename to ss/ssfilter.y
ss/ssfilter_check.c renamed from misc/ssfilter_check.c +0 -0
similarity index 100%
rename from misc/ssfilter_check.c
rename to ss/ssfilter_check.c
ss/summary.c new file +167 -0

167 lines not on this page · raw message

ss/tcp.c new file +623 -0

623 lines not on this page · raw message

ss/tipc.c new file +119 -0

119 lines not on this page · raw message

ss/unix.c new file +140 -0

140 lines not on this page · raw message

ss/users.c new file +333 -0

333 lines not on this page · raw message

ss/vsock.c new file +87 -0

87 lines not on this page · raw message

ss/xdp.c new file +170 -0

170 lines not on this page · raw message

testsuite/Makefile +1 -1
index 82f3f98c..70120594 100644

Lines of this file are not shown. View the raw message.

testsuite/tests/ss/ssfilter.t +1 -1
index cc0f01a5..b3fdab02 100755

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.53.0

Part of the diff is not shown here. View the raw message.