Commit 8a0eccb1056b313b45ab62e3aac400f339aa71b4
1 parent
e827fec2b2
Exists in
master
and in
54 other branches
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 |
include/net.h
... | ... | @@ -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) |
net/net.c