[PATCH 3/3] hwsim: support creating hwsim radio w/out vdev.

greearb at candelatech.com greearb at candelatech.com
Fri Oct 24 11:37:56 EDT 2014


From: Ben Greear <greearb at candelatech.com>

This way, you can create wlanX interfaces manually with
the desired name and don't have to worry about what the
kernel might call the auto-created one.   Should be helpful
for automated testing.

Signed-off-by: Ben Greear <greearb at candelatech.com>
---
 tests/hwsim/hwsim.py | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/tests/hwsim/hwsim.py b/tests/hwsim/hwsim.py
index dec273d..a5a385d 100644
--- a/tests/hwsim/hwsim.py
+++ b/tests/hwsim/hwsim.py
@@ -18,6 +18,7 @@ HWSIM_ATTR_CHANNELS		= 9
 HWSIM_ATTR_RADIO_ID		= 10
 HWSIM_ATTR_USE_CHANCTX		= 15
 HWSIM_ATTR_RADIO_NAME		= 17
+HWSIM_ATTR_NO_VDEV		= 18 # Create hwsim radio w/out auto-creating a vdev.
 
 # the controller class
 class HWSimController(object):
@@ -25,7 +26,7 @@ class HWSimController(object):
         self._conn = netlink.Connection(netlink.NETLINK_GENERIC)
         self._fid = netlink.genl_controller.get_family_id('MAC80211_HWSIM')
 
-    def create_radio(self, n_channels=None, use_chanctx=False, hwname=None):
+    def create_radio(self, n_channels=None, use_chanctx=False, hwname=None, no_vdev=False):
         attrs = []
         if n_channels:
             attrs.append(netlink.U32Attr(HWSIM_ATTR_CHANNELS, n_channels))
@@ -33,6 +34,8 @@ class HWSimController(object):
             attrs.append(netlink.FlagAttr(HWSIM_ATTR_USE_CHANCTX))
         if hwname:
             attrs.append(netlink.NulStrAttr(HWSIM_ATTR_RADIO_NAME, hwname))
+        if no_vdev:
+            attrs.append(netlink.FlagAttr(HWSIM_ATTR_NO_VDEV))
 
         msg = netlink.GenlMessage(self._fid, HWSIM_CMD_CREATE_RADIO,
                                   flags = netlink.NLM_F_REQUEST |
@@ -55,7 +58,8 @@ class HWSimController(object):
 def create(args):
     print 'Created radio %d' % c.create_radio(n_channels=args.channels,
                                               use_chanctx=args.chanctx,
-                                              hwname=args.radio_name)
+                                              hwname=args.radio_name,
+                                              no_vdev=args.no_vdev)
 
 def destroy(args):
     print c.destroy_radio(args.radio)
@@ -84,6 +88,10 @@ if __name__ == '__main__':
                                default="",
                                help='Optional radio name to request for the new ' +
                                'radio.')
+    parser_create.add_argument('--no_vdev', action="store_true",
+                               help='Ask kernel to NOT create wlanX interfaces. ' +
+                               'User could create them manually, with specific name '
+                               'for easier scripting and automated testing.')
     parser_create.set_defaults(func=create)
 
     parser_destroy = subparsers.add_parser('destroy', help='destroy a radio')
-- 
1.7.11.7



More information about the HostAP mailing list