Skip to content

Commit

Permalink
Reject incoming ethernet packets for other devices
Browse files Browse the repository at this point in the history
  • Loading branch information
olbjo committed Feb 17, 2021
1 parent 3017e02 commit 77ec6bc
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/common/pf_eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,18 @@ int pf_eth_recv (pnal_eth_handle_t * eth_handle, void * arg, pnal_buf_t * p_buf)
uint16_t ix = 0;
pnet_t * net = (pnet_t *)arg;

#ifndef UNIT_TEST
/* Reject unicast packets with destination not matching
* mac address of management interface.
*/
if (
(((uint8_t *)p_buf->payload)[0] != 1) &&
(memcmp (p_buf->payload, net->pf_interface.main_port.mac.addr, 6) != 0))
{
return 0;
}
#endif

/* Skip ALL VLAN tags */
p_data = (uint16_t *)(&((uint8_t *)p_buf->payload)[eth_type_pos]);
eth_type = ntohs (p_data[0]);
Expand Down

0 comments on commit 77ec6bc

Please sign in to comment.