Commit Graph

22 Commits

Author SHA1 Message Date
Rob Murray
084abd93d3 Add ErrDumpInterrupted
Add a specific error to report that a netlink response had
NLM_F_DUMP_INTR set, indicating that the set of results may be
incomplete or inconsistent.

unix.EINTR was previously returned (with no results) when the
NLM_F_DUMP_INTR flag was set. Now, errors.Is(err, unix.EINTR) will
still work. But, this will be a breaking change for any code that's
checking for equality with unix.EINTR.

Return results with ErrDumpInterrupted. Results may be incomplete
or inconsistent, but give the caller the option of using them.

Look for NLM_F_DUMP_INTR in more places:
- linkSubscribeAt, neighSubscribeAt, routeSubscribeAt
  - can do an initial dump, which may report inconsistent results
  -> if there's an error callback, call it with ErrDumpInterrupted
- socketDiagXDPExecutor
  - makes an NLM_F_DUMP request, without using Execute()
  -> give it the same behaviour as functions that do use Execute()

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-09-22 00:00:40 -07:00
Daman Arora
b1ce50cfa9 capture and return errors in ConntrackDeleteFilters
Signed-off-by: Daman Arora <aroradaman@gmail.com>
2024-09-05 11:07:32 -07:00
Etienne Champetier
92645823f3 Fix deprecated comments
Signed-off-by: Etienne Champetier <e.champetier@ateme.com>
2024-08-26 11:35:36 -07:00
Sebastiaan van Stijn
298ff277ed Handle: add ConntrackDeleteFilter alias for backward compat
Commit c96b03b4be changed the signature
of this method to accept a list of filters and renamed it to
ConntrackDeleteFilters (plural).

This patch

- adds back ConntrackDeleteFilter as an alias
- marks it as deprecated in favor of the new version.
- adds missing stubs for other platforms

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-23 12:31:44 -07:00
Daman Arora
3b7e16c5f8 Add ConntrackDeleteFilters
ConntrackDeleteFilters enables users to delete flow entries
that match any of the specified filters. This allows users
to delete multiple flow entries with a single dump table call.

Signed-off-by: Daman Arora <aroradaman@gmail.com>
2024-08-06 10:33:35 -07:00
Alex O'Regan
aed23dbf5e Adds ConntrackCreate & ConntrackUpdate
- Also refactored setUpNetlinkTestWithKModule function to reduce redundant NS's created and checks made.

 - Add conntrack protoinfo TCP support + groundwork for other protocols.

 - Tests to cover the above.
2024-07-04 08:47:44 -07:00
Hongliang Liu
99ce943af8 Add zone filter to conntrack 2024-04-10 11:23:27 -07:00
Surya Seetharaman
8e1ce9665a Add labelFilter for conntrack
This PR adds support for filtering flows
based on conntrack labels. It adds two
filters `ConntrackMatchLabels` &&
`ConntackUnmatchLabels` through which user can
provide a list of labels as type "bytes" which
will then be compared to flow.Labels to see if
any matches were found.

ConntrackMatchLabels: Every label passed should
be contained in flow.Labels for a match to be true
ConntrackUmmatchLabels: Every label passed should
not be contained in the flow.Labels for a match to
be true

Signed-off-by: Surya Seetharaman <suryaseetharaman.9@gmail.com>
2022-11-03 10:05:53 -07:00
GopiKrishna Kodali
607db9998a Fix netlink to skip reading TLVs that we are not interested.
Signed-off-by: GopiKrishna Kodali <gkodali@zededa.com>
2021-09-17 19:01:08 -07:00
Naiming Shen
fbf10179ff add timestamp/timeout to netlink/conntrack
Signed-off-by: Naiming Shen <naiming@zededa.com>
2021-09-17 19:01:08 -07:00
Antonio Ojea
a3836f0b5d conntrack: allow to filter by subnet
Add a new conntrack filter to be able to filter by subnet, in
addition to current IP address filter.

Signed-off-by: Antonio Ojea <aojea@redhat.com>
2021-05-08 17:46:37 -07:00
Antonio Ojea
bca67dfc82 conntrack filter by port and protocol
Add a new method to the ConntrackFilter to be able to
filter conntrack entries by Layer 4 protocol and source
and destination port.

Signed-off-by: Antonio Ojea <aojea@redhat.com>
2020-06-25 10:50:47 -07:00
Tobias Klauser
36d367fd76 Remove unused *_PROTO constants
These are unused since commit 941b4de9e1

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2019-09-13 09:58:27 -07:00
GopiKrishna Kodali
941b4de9e1 Read connection marking information from CT flow TLV 2019-08-23 11:20:03 -07:00
Flavio Crisciani
02a383156a Adjust conntrack filters
Today the filter implementation implements
only ip matching for src,dst,reply src,reply dst.
Updating the comments on the filter to reflect that
more clearly and deprecate confusing constants

Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>
2018-10-24 12:03:49 -07:00
Yang Guan
41009d533b Read conntrack flow statistics
This PR allows populating per-connection packet and byte counts to
ConntrackFlow object when nf_conntrack_acct is enabled.
2018-03-16 14:29:24 -07:00
Ian Bishop
0e3b74dbe2 replace syscall with golang.org/x/sys/unix 2017-10-26 09:45:08 -07:00
Sibi Chakravarthy
8d7f7aad19 added missing mark in Sprintf 2017-07-18 16:23:47 -07:00
sibi
a56439f1e4 added-mark 2017-07-18 14:16:10 -07:00
Shaun Crampton
6e453822d8 Make conntrack filter into an interface to allow for custom filters. 2017-06-30 11:43:20 -07:00
Flavio Crisciani
1e86b2bee5 AddIP prototype change and fix for go 1.6
Removed extra pointer not needed in AddIP
Updated tests

Removed the use of io.SeekCurrent and defined it as a const

Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>
2017-04-07 11:04:30 -07:00
Flavio Crisciani
24a3a2da61 Introduce Conntrack support
- Conntrack table FLUSH
- Conntrack table DELETE with filter
    The filter is only for IP field
- Conntrack table GET
  The flow information is not complete, but the method
  returns a simplified structure with basic flow info

Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>
2017-04-05 16:02:07 -07:00