RFE: React component for editing MAC addresses


our current MAC address field is just a text box. We do a check in the code base for multicast MAC, broadcast and valid MAC address. A React component could do the unicast and multicast check and display a warning if such a macaddress is entered, so we could remove those validators from Rails as a hard requirement.

Looks like either Dell ships such MACs or users changed it for some reason: Bug #27852: Cannot add host with interface mac address in e3:xx:xx:xx - Foreman

    def self.multicast_mac?(mac)
      return false unless validate_mac(mac)

      # Get the first byte
      msb = mac.tr('.:-', '').slice(0..1).to_i(16)

      # Is least significant bit set?
      msb & 0b1 == 1
    def self.broadcast_mac?(mac)
      return false unless validate_mac(mac)
      mac.downcase == 'ff:ff:ff:ff:ff:ff'

Any volunteer to create and implement such a component for Edit NIC form? :wink: I will happily review and test the stuff.

1 Like

I think we should keep 'em, at least for the API. Frontend validation is nice for the user experience, but we should imho always have server side validation as well.

What do you recommend to reply to the user? I can’t tell if Dell is shipping those MAC addresses.

Can we ask the user about this? :slight_smile:

1 Like