diff --git a/go.mod b/go.mod index 8ea194abc4c..569592434be 100644 --- a/go.mod +++ b/go.mod @@ -36,7 +36,7 @@ require ( github.com/google/gnostic-models v0.6.9 github.com/google/go-cmp v0.7.0 github.com/google/uuid v1.6.0 - github.com/ishidawataru/sctp v0.0.0-20230406120618-7ff4192f6ff2 + github.com/ishidawataru/sctp v0.0.0-20250521072954-ae8eb7fa7995 github.com/libopenstorage/openstorage v1.0.0 github.com/lithammer/dedent v1.1.0 github.com/moby/ipvs v1.1.0 diff --git a/go.sum b/go.sum index 6ea1ae8367c..36d6308ab96 100644 --- a/go.sum +++ b/go.sum @@ -185,8 +185,8 @@ github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3/go.mod h1:ndYquD05frm2vACXE1ns github.com/ianlancetaylor/demangle v0.0.0-20240312041847-bd984b5ce465/go.mod h1:gx7rwoVhcfuVKG5uya9Hs3Sxj7EIvldVofAWIUtGouw= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= -github.com/ishidawataru/sctp v0.0.0-20230406120618-7ff4192f6ff2 h1:i2fYnDurfLlJH8AyyMOnkLHnHeP8Ff/DDpuZA/D3bPo= -github.com/ishidawataru/sctp v0.0.0-20230406120618-7ff4192f6ff2/go.mod h1:co9pwDoBCm1kGxawmb4sPq0cSIOOWNPT4KnHotMP1Zg= +github.com/ishidawataru/sctp v0.0.0-20250521072954-ae8eb7fa7995 h1:GtGlZy0FQTUGKSGVhzFZixkUXnpRj7s1rKEegNZcy9Y= +github.com/ishidawataru/sctp v0.0.0-20250521072954-ae8eb7fa7995/go.mod h1:co9pwDoBCm1kGxawmb4sPq0cSIOOWNPT4KnHotMP1Zg= github.com/jonboulle/clockwork v0.5.0 h1:Hyh9A8u51kptdkR+cqRpT1EebBwTn1oK9YfGYbdFz6I= github.com/jonboulle/clockwork v0.5.0/go.mod h1:3mZlmanh0g2NDKO5TWZVJAfofYk64M7XN3SzBPjZF60= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= diff --git a/hack/unwanted-dependencies.json b/hack/unwanted-dependencies.json index 27ca1f485c2..b6be21d38c2 100644 --- a/hack/unwanted-dependencies.json +++ b/hack/unwanted-dependencies.json @@ -1,10 +1,6 @@ { "spec": { "pinnedModules": { - "github.com/ishidawataru/sctp": { - "Version": "v0.0.0-20230406120618-7ff4192f6ff2", - "Reason": "broken module, do not update until https://github.com/ishidawataru/sctp/pull/75 is fixed" - }, "github.com/libopenstorage/openstorage": { "Version": "v1.0.0", "Reason": "portworx csi driver has been deprecated and will be removed - https://github.com/kubernetes/enhancements/issues/2589" diff --git a/vendor/github.com/ishidawataru/sctp/sctp.go b/vendor/github.com/ishidawataru/sctp/sctp.go index add951a2de0..32ff2ac7234 100644 --- a/vendor/github.com/ishidawataru/sctp/sctp.go +++ b/vendor/github.com/ishidawataru/sctp/sctp.go @@ -83,7 +83,10 @@ const ( SCTP_EVENT_ALL = SCTP_EVENT_DATA_IO | SCTP_EVENT_ASSOCIATION | SCTP_EVENT_ADDRESS | SCTP_EVENT_SEND_FAILURE | SCTP_EVENT_PEER_ERROR | SCTP_EVENT_SHUTDOWN | SCTP_EVENT_PARTIAL_DELIVERY | SCTP_EVENT_ADAPTATION_LAYER | SCTP_EVENT_AUTHENTICATION | SCTP_EVENT_SENDER_DRY ) -type SCTPNotificationType int +type ( + SCTPNotificationType int + SCTPAssocID int32 +) const ( SCTP_SN_TYPE_BASE = SCTPNotificationType(iota + (1 << 15)) @@ -140,6 +143,60 @@ type InitMsg struct { MaxInitTimeout uint16 } +// SackTimer Parameters defined in RFC 6458 8.1.19 - SCTP_DELAYED_SACK Delayed Sack Timer sack_timeout +type SackTimer struct { + AssocID SCTPAssocID + SackDelay uint32 + SackFrequency uint32 +} + +type PeerState int32 + +const ( + SCTP_UNCONFIRMED PeerState = iota + SCTP_ACTIVE + SCTP_INACTIVE +) + +// PeerAddrinfo Parameters defined in RFC 6458 8.2.2 - Peer Address Information (SCTP_GET_PEER_ADDR_INFO) +type PeerAddrinfo struct { + AssocID SCTPAssocID + Address [128]byte // if needed from here, retrieve using resolveFromRawAddr(unsafe.Pointer(&PeerAddrinfo.Address), 1), or get it from *SCTPConn.SCTPGetPrimaryPeerAddr() + State PeerState + CWND uint32 + SRTT uint32 + RTO uint32 + MTU uint32 +} + +type StatusState int32 + +const ( + SCTP_CLOSED StatusState = iota + SCTP_BOUND + SCTP_LISTEN + SCTP_COOKIE_WAIT + SCTP_COOKIE_ECHOED + SCTP_ESTABLISHED + SCTP_SHUTDOWN_PENDING + SCTP_SHUTDOWN_SENT + SCTP_SHUTDOWN_RECEIVED + SCTP_SHUTDOWN_ACK_SENT +) + +// Status Parameters defined in RFC 6458 8.2.1 - Association Status (SCTP_STATUS) +type Status struct { + AssocID SCTPAssocID + State StatusState + RWND uint32 + Unackdata uint16 + Penddata uint16 + Instreams uint16 + Ostreams uint16 + FragmentationPoint uint32 + PrimaryPeerAddr PeerAddrinfo +} + type SndRcvInfo struct { Stream uint16 SSN uint16 @@ -505,6 +562,36 @@ func (c *SCTPConn) GetDefaultSentParam() (*SndRcvInfo, error) { return info, err } +func (c *SCTPConn) SetSackTimer(timer *SackTimer) error { // SackTimer + optlen := unsafe.Sizeof(*timer) + _, _, err := setsockopt(c.fd(), SCTP_DELAYED_SACK, uintptr(unsafe.Pointer(timer)), optlen) + return err +} + +func (c *SCTPConn) GetSackTimer() (*SackTimer, error) { // SackTimer + timer := &SackTimer{} + optlen := unsafe.Sizeof(*timer) + _, _, err := getsockopt( + c.fd(), + SCTP_DELAYED_SACK, + uintptr(unsafe.Pointer(timer)), + uintptr(unsafe.Pointer(&optlen)), + ) + return timer, err +} + +func (c *SCTPConn) GetStatus() (*Status, error) { // Status + sctpStatus := &Status{} + optlen := unsafe.Sizeof(*sctpStatus) + _, _, err := getsockopt( + c.fd(), + SCTP_STATUS, + uintptr(unsafe.Pointer(sctpStatus)), + uintptr(unsafe.Pointer(&optlen)), + ) + return sctpStatus, err +} + func (c *SCTPConn) Getsockopt(optname, optval, optlen uintptr) (uintptr, uintptr, error) { return getsockopt(c.fd(), optname, optval, optlen) } @@ -636,8 +723,9 @@ func (c *SCTPConn) SetWriteDeadline(t time.Time) error { } type SCTPListener struct { - fd int - m sync.Mutex + fd int + m sync.Mutex + notificationHandler NotificationHandler } func (ln *SCTPListener) Addr() net.Addr { @@ -723,15 +811,16 @@ type SocketConfig struct { // If Control is not nil it is called after the socket is created but before // it is bound or connected. Control func(network, address string, c syscall.RawConn) error - + // NotificationHandler defines actions taken on received notifications when MSG_NOTIFICATION flag is set. + NotificationHandler NotificationHandler // InitMsg is the options to send in the initial SCTP message InitMsg InitMsg } func (cfg *SocketConfig) Listen(net string, laddr *SCTPAddr) (*SCTPListener, error) { - return listenSCTPExtConfig(net, laddr, cfg.InitMsg, cfg.Control) + return listenSCTPExtConfig(net, laddr, cfg.InitMsg, cfg.Control, cfg.NotificationHandler) } func (cfg *SocketConfig) Dial(net string, laddr, raddr *SCTPAddr) (*SCTPConn, error) { - return dialSCTPExtConfig(net, laddr, raddr, cfg.InitMsg, cfg.Control) + return dialSCTPExtConfig(net, laddr, raddr, cfg.InitMsg, cfg.Control, cfg.NotificationHandler) } diff --git a/vendor/github.com/ishidawataru/sctp/sctp_linux.go b/vendor/github.com/ishidawataru/sctp/sctp_linux.go index e11d012cff4..10b36453815 100644 --- a/vendor/github.com/ishidawataru/sctp/sctp_linux.go +++ b/vendor/github.com/ishidawataru/sctp/sctp_linux.go @@ -1,4 +1,6 @@ +//go:build linux && !386 // +build linux,!386 + // Copyright 2019 Wataru Ishida. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,10 +21,10 @@ package sctp import ( "io" "net" + "runtime" "sync/atomic" "syscall" "unsafe" - "runtime" ) func setsockopt(fd int, optname, optval, optlen uintptr) (uintptr, uintptr, error) { @@ -172,11 +174,11 @@ func ListenSCTP(net string, laddr *SCTPAddr) (*SCTPListener, error) { // ListenSCTPExt - start listener on specified address/port with given SCTP options func ListenSCTPExt(network string, laddr *SCTPAddr, options InitMsg) (*SCTPListener, error) { - return listenSCTPExtConfig(network, laddr, options, nil) + return listenSCTPExtConfig(network, laddr, options, nil, nil) } // listenSCTPExtConfig - start listener on specified address/port with given SCTP options and socket configuration -func listenSCTPExtConfig(network string, laddr *SCTPAddr, options InitMsg, control func(network, address string, c syscall.RawConn) error) (*SCTPListener, error) { +func listenSCTPExtConfig(network string, laddr *SCTPAddr, options InitMsg, control func(network, address string, c syscall.RawConn) error, notificationHandler NotificationHandler) (*SCTPListener, error) { af, ipv6only := favoriteAddrFamily(network, laddr, nil, "listen") sock, err := syscall.Socket( af, @@ -198,7 +200,11 @@ func listenSCTPExtConfig(network string, laddr *SCTPAddr, options InitMsg, contr } if control != nil { rc := rawConn{sockfd: sock} - if err = control(network, laddr.String(), rc); err != nil { + var localAddressString string + if laddr != nil { + localAddressString = laddr.String() + } + if err = control(network, localAddressString, rc); err != nil { return nil, err } } @@ -226,14 +232,16 @@ func listenSCTPExtConfig(network string, laddr *SCTPAddr, options InitMsg, contr return nil, err } return &SCTPListener{ - fd: sock, - }, nil + fd: sock, + notificationHandler: notificationHandler, + }, + nil } // AcceptSCTP waits for and returns the next SCTP connection to the listener. func (ln *SCTPListener) AcceptSCTP() (*SCTPConn, error) { fd, _, err := syscall.Accept4(ln.fd, 0) - return NewSCTPConn(fd, nil), err + return NewSCTPConn(fd, ln.notificationHandler), err } // Accept waits for and returns the next connection connection to the listener. @@ -253,11 +261,11 @@ func DialSCTP(net string, laddr, raddr *SCTPAddr) (*SCTPConn, error) { // DialSCTPExt - same as DialSCTP but with given SCTP options func DialSCTPExt(network string, laddr, raddr *SCTPAddr, options InitMsg) (*SCTPConn, error) { - return dialSCTPExtConfig(network, laddr, raddr, options, nil) + return dialSCTPExtConfig(network, laddr, raddr, options, nil, nil) } // dialSCTPExtConfig - same as DialSCTP but with given SCTP options and socket configuration -func dialSCTPExtConfig(network string, laddr, raddr *SCTPAddr, options InitMsg, control func(network, address string, c syscall.RawConn) error) (*SCTPConn, error) { +func dialSCTPExtConfig(network string, laddr, raddr *SCTPAddr, options InitMsg, control func(network, address string, c syscall.RawConn) error, notificationHandler NotificationHandler) (*SCTPConn, error) { af, ipv6only := favoriteAddrFamily(network, laddr, raddr, "dial") sock, err := syscall.Socket( af, @@ -279,7 +287,11 @@ func dialSCTPExtConfig(network string, laddr, raddr *SCTPAddr, options InitMsg, } if control != nil { rc := rawConn{sockfd: sock} - if err = control(network, laddr.String(), rc); err != nil { + var localAddressString string + if laddr != nil { + localAddressString = laddr.String() + } + if err = control(network, localAddressString, rc); err != nil { return nil, err } } @@ -305,5 +317,5 @@ func dialSCTPExtConfig(network string, laddr, raddr *SCTPAddr, options InitMsg, if err != nil { return nil, err } - return NewSCTPConn(sock, nil), nil + return NewSCTPConn(sock, notificationHandler), nil } diff --git a/vendor/github.com/ishidawataru/sctp/sctp_unsupported.go b/vendor/github.com/ishidawataru/sctp/sctp_unsupported.go index 118fe159e92..bc351c67125 100644 --- a/vendor/github.com/ishidawataru/sctp/sctp_unsupported.go +++ b/vendor/github.com/ishidawataru/sctp/sctp_unsupported.go @@ -69,7 +69,7 @@ func ListenSCTPExt(net string, laddr *SCTPAddr, options InitMsg) (*SCTPListener, return nil, ErrUnsupported } -func listenSCTPExtConfig(network string, laddr *SCTPAddr, options InitMsg, control func(network, address string, c syscall.RawConn) error) (*SCTPListener, error) { +func listenSCTPExtConfig(network string, laddr *SCTPAddr, options InitMsg, control func(network string, address string, c syscall.RawConn) error, handler NotificationHandler) (*SCTPListener, error) { return nil, ErrUnsupported } @@ -93,6 +93,6 @@ func DialSCTPExt(network string, laddr, raddr *SCTPAddr, options InitMsg) (*SCTP return nil, ErrUnsupported } -func dialSCTPExtConfig(network string, laddr, raddr *SCTPAddr, options InitMsg, control func(network, address string, c syscall.RawConn) error) (*SCTPConn, error) { +func dialSCTPExtConfig(network string, laddr, raddr *SCTPAddr, options InitMsg, control func(network string, address string, c syscall.RawConn) error, handler NotificationHandler) (*SCTPConn, error) { return nil, ErrUnsupported } diff --git a/vendor/modules.txt b/vendor/modules.txt index b4ff76350f5..0d004c79171 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -334,7 +334,7 @@ github.com/grpc-ecosystem/grpc-gateway/v2/utilities # github.com/inconshreveable/mousetrap v1.1.0 ## explicit; go 1.18 github.com/inconshreveable/mousetrap -# github.com/ishidawataru/sctp v0.0.0-20230406120618-7ff4192f6ff2 +# github.com/ishidawataru/sctp v0.0.0-20250521072954-ae8eb7fa7995 ## explicit; go 1.12 github.com/ishidawataru/sctp # github.com/jonboulle/clockwork v0.5.0