mirage / mirage-vnetif

Virtual network interface and software bridge for Mirage
ISC License
16 stars 13 forks source link

Mac address lookups may throw Not_found #32

Open MagnusS opened 4 years ago

MagnusS commented 4 years ago

If the network interface isn't registered in the backend a call to mac will throw Not_found. This can happen if a previously registered netif has called Vnetif.disconnect and a background process attempts to send more ethernet frames with Ethernet.write. See also discussion in https://github.com/mirage/mirage-tcpip/pull/428

It's not clear what the best way to fail here would be, as the mac function has to return an address or raise an exception. Options to consider:

  1. Return generated mac or a fixed mac -- random mac addresses may be hard to debug in recorded pcap data, and will later most likely cause a new exception in a call to write
  2. Remember original mac even after calls to disconnect/unregister so mac wouldn't fail. This also requires an update to write to drop packets without a valid source
  3. Throw a more useful exception