This is an automated email from the ASF dual-hosted git repository.
liuhan pushed a commit to branch reduce-handle-connect-time
in repository https://gitbox.apache.org/repos/asf/skywalking-rover.git
The following commit(s) were added to refs/heads/reduce-handle-connect-time by
this push:
new ba4f965 update conntrack
ba4f965 is described below
commit ba4f9650be79a5bb19378a6b4445442e17e47357
Author: mrproliu <[email protected]>
AuthorDate: Sat Dec 28 15:48:29 2024 +0800
update conntrack
---
pkg/tools/ip/conntrack.go | 78 +++++++++++++++++++++++------------------------
1 file changed, 39 insertions(+), 39 deletions(-)
diff --git a/pkg/tools/ip/conntrack.go b/pkg/tools/ip/conntrack.go
index 124476e..88b868a 100644
--- a/pkg/tools/ip/conntrack.go
+++ b/pkg/tools/ip/conntrack.go
@@ -58,6 +58,45 @@ func NewConnTrack() (*ConnTrack, error) {
return nil, err
}
+ go func() {
+ client, _ := conntrack.Dial(nil)
+ evCh := make(chan conntrack.Event, 2048)
+
+ errCh, err := client.Listen(evCh, 4, []netfilter.NetlinkGroup{
+ netfilter.GroupCTNew, // watching for new conntrack
events
+ })
+ if err != nil {
+ log.Errorf("++++++: %v", err)
+ }
+
+ client.SetReadBuffer(26214400) // 25MB
+ // Listen to Conntrack events from all network namespaces on
the system.
+ err = client.SetOption(netlink.ListenAllNSID, true)
+ if err != nil {
+ log.Errorf("0-------: %v", err)
+ }
+
+ // Start a goroutine to print all incoming messages on the
event channel.
+ go func() {
+ for {
+ e := <-evCh
+ if e.Flow.TupleOrig.Proto.DestinationPort == 53
{
+ continue
+ }
+ log.Infof("conntrack: type: %s, origin:
%s:%d->%s:%d, reply: %s:%d->%s:%d", e.Type,
+ e.Flow.TupleOrig.IP.SourceAddress,
e.Flow.TupleOrig.Proto.SourcePort,
+ e.Flow.TupleOrig.IP.DestinationAddress,
e.Flow.TupleOrig.Proto.DestinationPort,
+ e.Flow.TupleReply.IP.SourceAddress,
e.Flow.TupleReply.Proto.SourcePort,
+
e.Flow.TupleReply.IP.DestinationAddress,
e.Flow.TupleReply.Proto.DestinationPort)
+ }
+ }()
+
+ // Stop the program as soon as an error is caught in a decoder
goroutine.
+ if err := <-errCh; err != nil {
+ log.Errorf("conntrack error: %v", err)
+ }
+ }()
+
return &ConnTrack{
queryClient: queryClient,
eventChain: make(chan conntrack.Event, 2048),
@@ -107,45 +146,6 @@ func (c *ConnTrack) monitor0(ctx context.Context) (chan
error, error) {
}
}
- go func() {
- client, _ := conntrack.Dial(nil)
- evCh := make(chan conntrack.Event, 2048)
-
- errCh, err := client.Listen(evCh, 4, []netfilter.NetlinkGroup{
- netfilter.GroupCTNew, // watching for new conntrack
events
- })
- if err != nil {
- log.Errorf("++++++: %v", err)
- }
-
- client.SetReadBuffer(26214400) // 25MB
- // Listen to Conntrack events from all network namespaces on
the system.
- err = client.SetOption(netlink.ListenAllNSID, true)
- if err != nil {
- log.Errorf("0-------: %v", err)
- }
-
- // Start a goroutine to print all incoming messages on the
event channel.
- go func() {
- for {
- e := <-evCh
- if e.Flow.TupleOrig.Proto.DestinationPort == 53
{
- continue
- }
- log.Infof("conntrack: type: %s, origin:
%s:%d->%s:%d, reply: %s:%d->%s:%d", e.Type,
- e.Flow.TupleOrig.IP.SourceAddress,
e.Flow.TupleOrig.Proto.SourcePort,
- e.Flow.TupleOrig.IP.DestinationAddress,
e.Flow.TupleOrig.Proto.DestinationPort,
- e.Flow.TupleReply.IP.SourceAddress,
e.Flow.TupleReply.Proto.SourcePort,
-
e.Flow.TupleReply.IP.DestinationAddress,
e.Flow.TupleReply.Proto.DestinationPort)
- }
- }()
-
- // Stop the program as soon as an error is caught in a decoder
goroutine.
- if err := <-errCh; err != nil {
- log.Errorf("conntrack error: %v", err)
- }
- }()
-
cl, err := conntrack.Dial(nil)
if err != nil {
return nil, err