summaryrefslogtreecommitdiffhomepage
path: root/pkg/tcpip/transport/raw
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2020-03-26 22:49:28 +0000
committergVisor bot <gvisor-bot@google.com>2020-03-26 22:49:28 +0000
commit9699018b4ab2b2ca9abb3170abff4ab630238641 (patch)
treeccc43fb184215226265ede5412a2ed3ca6bed433 /pkg/tcpip/transport/raw
parent98c58a207c4b3dfc9dd9b0d0ccab4e85fe82be75 (diff)
parent0e62a548eb093c95e41780c753afa87f4ccc5c8f (diff)
Merge release-20200219.0-249-g0e62a54 (automated)
Diffstat (limited to 'pkg/tcpip/transport/raw')
-rw-r--r--pkg/tcpip/transport/raw/endpoint.go9
-rwxr-xr-xpkg/tcpip/transport/raw/raw_state_autogen.go2
2 files changed, 11 insertions, 0 deletions
diff --git a/pkg/tcpip/transport/raw/endpoint.go b/pkg/tcpip/transport/raw/endpoint.go
index 536dafd1e..337bc1c71 100644
--- a/pkg/tcpip/transport/raw/endpoint.go
+++ b/pkg/tcpip/transport/raw/endpoint.go
@@ -80,6 +80,9 @@ type endpoint struct {
// Connect(), and is valid only when conneted is true.
route stack.Route `state:"manual"`
stats tcpip.TransportEndpointStats `state:"nosave"`
+
+ // owner is used to get uid and gid of the packet.
+ owner tcpip.PacketOwner
}
// NewEndpoint returns a raw endpoint for the given protocols.
@@ -159,6 +162,10 @@ func (e *endpoint) Close() {
// ModerateRecvBuf implements tcpip.Endpoint.ModerateRecvBuf.
func (e *endpoint) ModerateRecvBuf(copied int) {}
+func (e *endpoint) SetOwner(owner tcpip.PacketOwner) {
+ e.owner = owner
+}
+
// IPTables implements tcpip.Endpoint.IPTables.
func (e *endpoint) IPTables() (stack.IPTables, error) {
return e.stack.IPTables(), nil
@@ -348,10 +355,12 @@ func (e *endpoint) finishWrite(payloadBytes []byte, route *stack.Route) (int64,
}
break
}
+
hdr := buffer.NewPrependable(len(payloadBytes) + int(route.MaxHeaderLength()))
if err := route.WritePacket(nil /* gso */, stack.NetworkHeaderParams{Protocol: e.TransProto, TTL: route.DefaultTTL(), TOS: stack.DefaultTOS}, stack.PacketBuffer{
Header: hdr,
Data: buffer.View(payloadBytes).ToVectorisedView(),
+ Owner: e.owner,
}); err != nil {
return 0, nil, err
}
diff --git a/pkg/tcpip/transport/raw/raw_state_autogen.go b/pkg/tcpip/transport/raw/raw_state_autogen.go
index 41b72cf93..c755fa847 100755
--- a/pkg/tcpip/transport/raw/raw_state_autogen.go
+++ b/pkg/tcpip/transport/raw/raw_state_autogen.go
@@ -39,6 +39,7 @@ func (x *endpoint) save(m state.Map) {
m.Save("closed", &x.closed)
m.Save("connected", &x.connected)
m.Save("bound", &x.bound)
+ m.Save("owner", &x.owner)
}
func (x *endpoint) load(m state.Map) {
@@ -52,6 +53,7 @@ func (x *endpoint) load(m state.Map) {
m.Load("closed", &x.closed)
m.Load("connected", &x.connected)
m.Load("bound", &x.bound)
+ m.Load("owner", &x.owner)
m.LoadValue("rcvBufSizeMax", new(int), func(y interface{}) { x.loadRcvBufSizeMax(y.(int)) })
m.AfterLoad(x.afterLoad)
}