History

inet_diag: Add equal-operator for ports

inet_diag currently provides less/greater than or equal operators for comparing ports when filtering sockets. An equal comparison can be performed by combining the two existing operators, or a user can for example request a port range and then do the final filtering in userspace. However, these approaches both have drawbacks. Implementing equal using LE/GE causes the size and complexity of a filter to grow quickly as the number of ports increase, while it on busy machines would be great if the kernel only returns information about relevant sockets. This patch introduces source and destination port equal operators. INET_DIAG_BC_S_EQ is used to match a source port, INET_DIAG_BC_D_EQ a destination port, and usage is the same as for the existing port operators. I.e., the port to match is stored in the no-member of the next inet_diag_bc_op-struct in the filter.

Kristian Evensen committed 8 years ago

Commit bbb61891 parent d323b522 files · +10 −0Browse files

Showing the changes to include/uapi/linux (1 of 2 files). Show all

Unified · Split

include/uapi/linux/inet_diag.h+2−0
@@ -92,6 +92,8 @@ enum { · 91 unmodified lines
9292 INET_DIAG_BC_D_COND,
9393 INET_DIAG_BC_DEV_COND, /* u32 ifindex */
9494 INET_DIAG_BC_MARK_COND,
95+ INET_DIAG_BC_S_EQ,
96+ INET_DIAG_BC_D_EQ,
9597 };
9698
9799 struct inet_diag_hostcond {