File tree Expand file tree Collapse file tree 2 files changed +39
-14
lines changed
Expand file tree Collapse file tree 2 files changed +39
-14
lines changed Original file line number Diff line number Diff line change @@ -181,13 +181,27 @@ impl InterfaceInner {
181181 {
182182 // Ignore IP packets not directed at us, or broadcast, or any of the multicast groups.
183183 // If AnyIP is enabled, also check if the packet is routed locally.
184- if !self . any_ip
185- || !ipv4_repr. dst_addr . x_is_unicast ( )
186- || self
187- . routes
188- . lookup ( & IpAddress :: Ipv4 ( ipv4_repr. dst_addr ) , self . now )
189- . map_or ( true , |router_addr| !self . has_ip_addr ( router_addr) )
184+
185+ if !self . any_ip {
186+ net_trace ! ( "Rejecting IPv4 packet; any_ip=false" ) ;
187+ return None ;
188+ }
189+
190+ if !ipv4_repr. dst_addr . x_is_unicast ( ) {
191+ net_trace ! (
192+ "Rejecting IPv4 packet; {} is not a unicast address" ,
193+ ipv4_repr. dst_addr
194+ ) ;
195+ return None ;
196+ }
197+
198+ if self
199+ . routes
200+ . lookup ( & IpAddress :: Ipv4 ( ipv4_repr. dst_addr ) , self . now )
201+ . map_or ( true , |router_addr| !self . has_ip_addr ( router_addr) )
190202 {
203+ net_trace ! ( "Rejecting IPv4 packet; no matching routes" ) ;
204+
191205 return None ;
192206 }
193207 }
Original file line number Diff line number Diff line change @@ -212,15 +212,26 @@ impl InterfaceInner {
212212 && !self . has_multicast_group ( ipv6_repr. dst_addr )
213213 && !ipv6_repr. dst_addr . is_loopback ( )
214214 {
215- // If AnyIP is enabled, also check if the packet is routed locally.
216- if !self . any_ip
217- || !ipv6_repr. dst_addr . x_is_unicast ( )
218- || self
219- . routes
220- . lookup ( & IpAddress :: Ipv6 ( ipv6_repr. dst_addr ) , self . now )
221- . map_or ( true , |router_addr| !self . has_ip_addr ( router_addr) )
215+ if !self . any_ip {
216+ net_trace ! ( "Rejecting IPv6 packet; any_ip=false" ) ;
217+ return None ;
218+ }
219+
220+ if !ipv6_repr. dst_addr . x_is_unicast ( ) {
221+ net_trace ! (
222+ "Rejecting IPv6 packet; {} is not a unicast address" ,
223+ ipv6_repr. dst_addr
224+ ) ;
225+ return None ;
226+ }
227+
228+ if self
229+ . routes
230+ . lookup ( & IpAddress :: Ipv6 ( ipv6_repr. dst_addr ) , self . now )
231+ . map_or ( true , |router_addr| !self . has_ip_addr ( router_addr) )
222232 {
223- net_trace ! ( "packet IP address not for this interface" ) ;
233+ net_trace ! ( "Rejecting IPv6 packet; no matching routes" ) ;
234+
224235 return None ;
225236 }
226237 }
You can’t perform that action at this time.
0 commit comments