@@ -59,7 +59,7 @@ func (r *icmpResponder) ok() bool {
5959
6060// handle returns true if the packet is ICMP and is handled (or dropped) by the
6161// bypass path.
62- func (r * icmpResponder ) handle (b buffer.Buffer ) (handled bool ) {
62+ func (r * icmpResponder ) handle (nic tcpip. NICID , b buffer.Buffer ) (handled bool ) {
6363 if ! r .ok () {
6464 return
6565 }
@@ -132,15 +132,15 @@ func (r *icmpResponder) handle(b buffer.Buffer) (handled bool) {
132132
133133 // Process asynchronously to avoid blocking the dispatcher loop.
134134 core .Go ("icmp.responder" , func () {
135- r .process (h , parsed , src , dst )
135+ r .process (h , nic , parsed , src , dst )
136136 })
137137
138138 return true
139139}
140140
141141// process handles the ICMP echo request and injects the reply back into the TUN.
142142// The parsed packet is released back to the pool after processing.
143- func (r * icmpResponder ) process (h GICMPHandler , pkt * wire.Parsed , src , dst netip.AddrPort ) {
143+ func (r * icmpResponder ) process (h GICMPHandler , nic tcpip. NICID , pkt * wire.Parsed , src , dst netip.AddrPort ) {
144144 defer wire .Pool .Put (pkt )
145145
146146 icmpMsg := pkt .Transport ()
@@ -170,7 +170,7 @@ func (r *icmpResponder) process(h GICMPHandler, pkt *wire.Parsed, src, dst netip
170170 return
171171 }
172172
173- r .inject (proto , resp )
173+ r .inject (nic , proto , resp )
174174}
175175
176176func (r * icmpResponder ) echoReply (pkt * wire.Parsed , d []byte , ok bool ) ([]byte , tcpip.NetworkProtocolNumber , string , error ) {
@@ -200,7 +200,7 @@ func (r *icmpResponder) echoReply(pkt *wire.Parsed, d []byte, ok bool) ([]byte,
200200 }
201201}
202202
203- func (r * icmpResponder ) inject (proto tcpip.NetworkProtocolNumber , packet []byte ) {
203+ func (r * icmpResponder ) inject (nic tcpip. NICID , proto tcpip.NetworkProtocolNumber , packet []byte ) {
204204 ep := r .ep
205205 if ep == nil || ! r .ok () {
206206 return
@@ -209,13 +209,14 @@ func (r *icmpResponder) inject(proto tcpip.NetworkProtocolNumber, packet []byte)
209209 pkt := stack .NewPacketBuffer (stack.PacketBufferOptions {
210210 Payload : buffer .MakeWithData (packet ),
211211 })
212+ pkt .NICID = nic
212213 defer pkt .DecRef ()
213214
214215 pkt .NetworkProtocolNumber = proto
215216 var list stack.PacketBufferList
216217 list .PushBack (pkt )
217218
218219 sz := pkt .Size ()
219- n , err := r . ep .WritePackets (list )
220+ n , err := ep .WritePackets (list )
220221 logeif (e (err ))("icmp: responder: inject %d to tun (n: %d; sz: %d); err? %v" , proto , n , sz , err )
221222}
0 commit comments