Jail MAC ADDRESS validation fails in "Advanced Jail Creation"

Description

Mac Address validation fails when I try to create a Jail in Advanced Jail Creation, while the Jail is created in standard mode.

MAC prefix for both jail: f4ce46

Py Exception from Middleware and Iocage at console:

Error: Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/iocage_lib/ioc_create.py", line 495, in _create_jail
value, config = iocjson.json_check_prop(key, value, config)
File "/usr/local/lib/python3.7/site-packages/iocage_lib/ioc_json.py", line 2440, in json_check_prop
silent=self.silent
File "/usr/local/lib/python3.7/site-packages/iocage_lib/ioc_common.py", line 103, in logit
callback(content, exception)
File "/usr/local/lib/python3.7/site-packages/iocage_lib/ioc_common.py", line 76, in callback
raise callback_exception(message)
RuntimeError: Invalid mac_prefix. Must match `?X????` where ? can be any valid hex digit (0-9, A-F) and X is one of 2, 6, A or E.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/middlewared/job.py", line 349, in run
await self.future
File "/usr/local/lib/python3.7/site-packages/middlewared/job.py", line 388, in __run_body
rv = await self.middleware.run_in_thread(self.method, *([self] + args))
File "/usr/local/lib/python3.7/site-packages/middlewared/utils/run_in_thread.py", line 10, in run_in_thread
return await self.loop.run_in_executor(self.run_in_thread_executor, functools.partial(method, *args, **kwargs))
File "/usr/local/lib/python3.7/site-packages/middlewared/utils/io_thread_pool_executor.py", line 25, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/local/lib/python3.7/site-packages/middlewared/schema.py", line 965, in nf
return f(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/middlewared/plugins/jail.py", line 771, in do_create
empty=empty
File "/usr/local/lib/python3.7/site-packages/iocage_lib/iocage.py", line 587, in create
clone_basejail=clone_basejail
File "/usr/local/lib/python3.7/site-packages/iocage_lib/ioc_create.py", line 100, in create_jail
return self._create_jail(jail_uuid, location)
File "/usr/local/lib/python3.7/site-packages/iocage_lib/ioc_create.py", line 501, in _create_jail
raise RuntimeError(f"**\n{err}\n**\n")
RuntimeError: ***
Invalid mac_prefix. Must match `?X????` where ? can be any valid hex digit (0-9, A-F) and X is one of 2, 6, A or E.

From iocage code in ioc_json.py:

elif key == 'mac_prefix':

  1. Invalid letters - 0,1,3,4,5,7,8,9,B,C,D,F

  2. Valid letters - 2,6,A,E
    if not self.validate_mac_prefix(value):
    iocage_lib.ioc_common.logit(
    {
    'level': 'EXCEPTION',
    'message': 'Invalid mac_prefix. Must match '
    '`?X????` where ? can be any '
    'valid hex digit (0-9, A-F) and '
    'X is one of 2, 6, A or E.'
    },
    _callback=self.callback,
    silent=self.silent
    )

So, f 4 ce46 won't match ? X ????

Workaround is easy... just choose a valid letter as second bit between 2, 6, A or E.

Problem/Justification

None

Impact

None

SmartDraw Connector

Katalon Manual Tests (BETA)

Activity

Show:

Bug Clerk 
June 9, 2020 at 7:06 PM

Bug Clerk 
June 7, 2020 at 11:56 AM

Bug Clerk 
June 7, 2020 at 11:53 AM

alessandro alessandro 
June 4, 2020 at 6:30 AM

Many thanks  for this clarification. I will check my default.json as soon as possible.

I would suggest to change this help string then:

mac_prefix

string

Optional. Enter a valid MAC address vendor prefix. Example: E-4-F4C6

This example could lead to that python exception if a distracted user user like me does not triple check his own input : - )

Anyway I agree that this behaviour is happening to a subset of user because I checked various posts in the jail forum and I noticed that the vast majority of submitted questions had valid mac_prefix values.

 

Waqar 
June 3, 2020 at 6:15 PM

Thank you for reporting this . So the behaviour is going to remain same for now at least from the UI perspective. What's going to happen is that in basic jail creation, you don't have the ability to specify mac prefix at all, so a sane value is chosen ensuring it's a valid mac prefix. However when creating jails using advanced section, it is expected user knows how to navigate those waters and correct mac prefix value if it's invalid.

Getting to how it can be invalid by default, a few months back a fix was merged to iocage where we made sure we don't have an invalid default mac prefix value, however this would only be true for cases where `defaults.json` had not been created already or in other words iocage hadn't been initialised. That is how a subset of users will experience this issue and to correct it at it's root, the best way is to modify defaults.json and update this value.

We have chosen not to do that implicitly because existing jail environments might be dependent on that and changing it would disrupt services there.

Complete

Details

Assignee

Reporter

Labels

Due date

Components

Fix versions

Affects versions

Priority

More fields

Katalon Platform

Created May 27, 2020 at 5:52 AM
Updated July 1, 2022 at 4:52 PM
Resolved June 9, 2020 at 7:06 PM