Commit 8a0eccb1056b313b45ab62e3aac400f339aa71b4

Authored by Joe Hershberger
1 parent e827fec2b2

net: Filter incoming netconsole packets by IP

Check the incoming packets' source IP address... if ncip isn't set to a
broadcast address, only listen to the client at ncip.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>

Showing 3 changed files with 9 additions and 3 deletions Side-by-side Diff

drivers/net/netconsole.c
... ... @@ -147,12 +147,16 @@
147 147 }
148 148 }
149 149  
150   -int nc_input_packet(uchar *pkt, unsigned dest, unsigned src, unsigned len)
  150 +int nc_input_packet(uchar *pkt, IPaddr_t src_ip, unsigned dest_port,
  151 + unsigned src_port, unsigned len)
151 152 {
152 153 int end, chunk;
153 154  
154   - if (dest != nc_in_port || !len)
  155 + if (dest_port != nc_in_port || !len)
155 156 return 0; /* not for us */
  157 +
  158 + if (src_ip != nc_ip && !is_broadcast(nc_ip))
  159 + return 0; /* not from our client */
156 160  
157 161 debug_cond(DEBUG_DEV_PKT, "input: \"%*.*s\"\n", len, len, pkt);
158 162  
... ... @@ -549,7 +549,8 @@
549 549  
550 550 #ifdef CONFIG_NETCONSOLE
551 551 void NcStart(void);
552   -int nc_input_packet(uchar *pkt, unsigned dest, unsigned src, unsigned len);
  552 +int nc_input_packet(uchar *pkt, IPaddr_t src_ip, unsigned dest_port,
  553 + unsigned src_port, unsigned len);
553 554 #endif
554 555  
555 556 static inline __attribute__((always_inline)) int eth_is_on_demand_init(void)
... ... @@ -1161,6 +1161,7 @@
1161 1161  
1162 1162 #ifdef CONFIG_NETCONSOLE
1163 1163 nc_input_packet((uchar *)ip + IP_UDP_HDR_SIZE,
  1164 + ntohl(ip->ip_src),
1164 1165 ntohs(ip->udp_dst),
1165 1166 ntohs(ip->udp_src),
1166 1167 ntohs(ip->udp_len) - UDP_HDR_SIZE);