1. 20 Nov, 2013 1 commit
  2. 30 Oct, 2013 4 commits
    • Luis R. Rodriguez's avatar
      crda: add regulatory domain optimizer · 0b8105a9
      Luis R. Rodriguez authored
      This adds a regulatory domain optimizer which can be
      used with information of a regulatory domain in db.txt
      format in stdin. It makes use of the new shiny regulatory
      domain stream parser.
      
      The way this works is it iterates over the regulatory domain
      computing unions between each frequency, starting from each
      frequency as a pivot. If a union leads to a valid regulatory
      rule we verify that the pivot and othre frequency rules that
      provided that valid union can fit into that union regulatory
      rule by computing an intersection. If an intersection is
      possible it means two rules can be optimized out. We do
      this repetitively.
      
      Note: cfg80211's nl80211.h API has:
      
            #define NL80211_MAX_SUPP_REG_RULES              32
      
      Our tools, both the stream parser and the optimizer are not
      limited to these artificial limits ! We can work on extending
      the kernel's limit but so far we have had no needs. A few
      notes below though on the existing reasoning for the limit
      and possible future enhancements.
      
      This is used nl80211_set_reg() upon intercept of a regulatory
      domain being sent from userspace to it. We picked a limitation
      to at least have a stopping gap to avoid userpace flooding the
      kernel with a denial of service requests on memory from userspace.
      This means that userspace can only request at most a kmalloc
      of up to 32 regulatory rules for processing for the regulatory
      data that we are copying from userspace. There's a Linux kernel
      enhancement that will be made soon so that we invalidate bogus
      requests, by checking to see if the incomming regulatory domain
      alpha2 was not expected upon a regulatory hint initiator (even
      if userspace first tells the kernel it is waiting for a response
      from kernel space), and if its invalid then we drop the userspace
      supplied request, therefore avoiding some form of flooding on
      memory to the kernel.
      
      Note that we can still get flooding if the userspace API is used
      to *request* to the kernel for a regulatory domain to be sent
      from userspace, in that case the kernel will properly expect the
      regulatory data for the alpha2. To prevent flooding there perhaps
      its a good idea for us to check whether a userspace pending request
      is pendingg and if so deny new updates until the last one triggers
      a timeout.
      
      Screenshot for a US file with 40 rules:
      
      mcgrof@frijol ~/devel/xlreg (git::master)$ cat us | grep --"(" | wc -l
      40
      
      mcgrof@frijol ~/devel/crda (git::master)$ cat us
      country US: DFS-FCC
              (2402.000 - 2422.000 @ 20.000), (30.00)
              (2407.000 - 2427.000 @ 20.000), (30.00)
              (2412.000 - 2432.000 @ 20.000), (30.00)
              (2417.000 - 2437.000 @ 20.000), (30.00)
              (2422.000 - 2442.000 @ 20.000), (30.00)
              (2427.000 - 2447.000 @ 20.000), (30.00)
              (2432.000 - 2452.000 @ 20.000), (30.00)
              (2437.000 - 2457.000 @ 20.000), (30.00)
              (2442.000 - 2462.000 @ 20.000), (30.00)
              (2447.000 - 2467.000 @ 20.000), (30.00)
              (2452.000 - 2472.000 @ 20.000), (30.00)
              (2402.000 - 2442.000 @ 40.000), (30.00)
              (2407.000 - 2447.000 @ 40.000), (30.00)
              (2412.000 - 2452.000 @ 40.000), (30.00)
              (2417.000 - 2457.000 @ 40.000), (30.00)
              (2422.000 - 2462.000 @ 40.000), (30.00)
              (2427.000 - 2467.000 @ 40.000), (30.00)
              (2432.000 - 2472.000 @ 40.000), (30.00)
              (5170.000 - 5190.000 @ 20.000), (17.00)
              (5190.000 - 5210.000 @ 20.000), (17.00)
              (5210.000 - 5230.000 @ 20.000), (17.00)
              (5230.000 - 5250.000 @ 20.000), (17.00)
              (5250.000 - 5270.000 @ 20.000), (23.00), DFS
              (5270.000 - 5290.000 @ 20.000), (23.00), DFS
              (5290.000 - 5310.000 @ 20.000), (23.00), DFS
              (5310.000 - 5330.000 @ 20.000), (23.00), DFS
              (5735.000 - 5755.000 @ 20.000), (30.00)
              (5755.000 - 5775.000 @ 20.000), (30.00)
              (5775.000 - 5795.000 @ 20.000), (30.00)
              (5795.000 - 5815.000 @ 20.000), (30.00)
              (5815.000 - 5835.000 @ 20.000), (30.00)
              (5170.000 - 5210.000 @ 40.000), (17.00)
              (5210.000 - 5250.000 @ 40.000), (17.00)
              (5250.000 - 5290.000 @ 40.000), (23.00), DFS
              (5290.000 - 5330.000 @ 40.000), (23.00), DFS
              (5735.000 - 5775.000 @ 40.000), (30.00)
              (5775.000 - 5815.000 @ 40.000), (30.00)
              (5170.000 - 5250.000 @ 80.000), (17.00)
              (5250.000 - 5330.000 @ 80.000), (23.00), DFS
              (5735.000 - 5815.000 @ 80.000), (30.00)
      
      mcgrof@frijol ~/devel/crda (git::master)$ cat us | ./optimize
      country US: DFS-FCC
              (2402.000 - 2472.000 @ 40.000), (30.00)
              (5170.000 - 5250.000 @ 80.000), (17.00)
              (5250.000 - 5330.000 @ 80.000), (23.00), DFS
              (5735.000 - 5835.000 @ 80.000), (30.00)
      
      I've also tested this with the current db.txt from wireless-regdb
      and get real optimiziations which I will post later.
      Signed-off-by: 's avatarLuis R. Rodriguez <mcgrof@do-not-panic.com>
      0b8105a9
    • Luis R. Rodriguez's avatar
      crda: add regulatory domain stream parser · 779cb492
      Luis R. Rodriguez authored
      This adds a stream parser for regulatory domains. This
      allows developers to build regulatory domains now using
      the db.txt from a stream, either stdin, or a from an
      opened file.
      
      This also adds a simple db2rd which for now only uses the
      library but with a bit of effort can also be used as a
      suitable replacement for the kernel's genregdb.awk.
      Signed-off-by: 's avatarLuis R. Rodriguez <mcgrof@do-not-panic.com>
      779cb492
    • Luis R. Rodriguez's avatar
      crda: remove antenna gain · 19942574
      Luis R. Rodriguez authored
      Signed-off-by: 's avatarLuis R. Rodriguez <mcgrof@do-not-panic.com>
      19942574
    • Luis R. Rodriguez's avatar
      crda: consolidate passive-scan and no-ibss flags · 3fb58aa0
      Luis R. Rodriguez authored
      We consolidate these two flags into one flag to indicate
      initiating radiation is not allowed.
      
      For parsing we'll treat the no-ibss flag moving forward
      as also passive-scan as well, newer kernels will always
      treat these equally, older kernels will use the still
      use them separately even though in practice they are
      used together interchangably.
      Signed-off-by: 's avatarLuis R. Rodriguez <mcgrof@do-not-panic.com>
      3fb58aa0
  3. 17 Jul, 2013 2 commits
    • Luis R. Rodriguez's avatar
      reglib: add reglib_is_valid_rd() and verify data upon build · 6145db24
      Luis R. Rodriguez authored
      This will verify the sanity of a regulatory domain upon build
      time. This is useful if you are making modifications to
      wireless-regdb and need to verify the regulatory domains
      won't be rejected by a similar checker. In the case of the
      Linux kernel regulatory domain data structures that get
      a complaint would have been rejected completely.
      Signed-off-by: 's avatarLuis R. Rodriguez <mcgrof@do-not-panic.com>
      6145db24
    • Ben Hutchings's avatar
      reglib: Validate all structure and array lengths · f4c3e3fc
      Ben Hutchings authored
      Add checks that:
      - Signature length does not exceed the file length (this was already
        checked, but did not account for signature lengths greater than 2 GB)
      - Database length is long enough for all structures we expect in it
      - Array length calculations will not overflow
      
      To keep these checks simple, change the types of array length and index
      variables to unsigned int (must be at least 32-bit, matching the file
      format) and the types of byte-length variables to size_t.
      
      Alexandre Rebert <alexandre@cmu.edu> reported and provided a test case
      for the signature length issue; the others I found by inspection.
      Signed-off-by: Ben Hutchings's avatarBen Hutchings <ben@decadent.org.uk>
      Signed-off-by: 's avatarLuis R. Rodriguez <mcgrof@do-not-panic.com>
      f4c3e3fc
  4. 31 May, 2013 10 commits
  5. 30 May, 2013 3 commits
  6. 29 May, 2013 3 commits
  7. 24 May, 2013 2 commits
  8. 21 Jan, 2013 1 commit
    • Luis R. Rodriguez's avatar
      crda: fix compile warning on pcc for reglib for string.h · 6a7fd50c
      Luis R. Rodriguez authored
      This fixes these compile warnings:
      
      make -j5 -l4 UDEV_RULE_DIR=/lib/udev/rules.d
      REG_BIN=/usr/lib64/crda/regulatory.bin USE_OPENSSL=1
      CC=x86_64-pc-linux-gnu-gcc all_noverify V=1
      x86_64-pc-linux-gnu-gcc -c  -Os -pipe -march=native
      -frecord-gcc-switches -ggdb -Wall -g -DUSE_OPENSSL
      -DPUBKEY_DIR=\"/etc/wireless-regdb/pubkeys\" `pkg-config --cflags
      openssl` -DCONFIG_LIBNL30 `pkg-config --cflags libnl-3.0` -o crda.o crda.c
      x86_64-pc-linux-gnu-gcc -c  -Os -pipe -march=native
      -frecord-gcc-switches -ggdb -Wall -g -DUSE_OPENSSL
      -DPUBKEY_DIR=\"/etc/wireless-regdb/pubkeys\" `pkg-config --cflags
      openssl` -DCONFIG_LIBNL30 `pkg-config --cflags libnl-3.0` -o intersect.o
      intersect.c
      ./utils/key2pub.py --ssl pubkeys/linville.key.pub.pem keys-ssl.c
      x86_64-pc-linux-gnu-gcc -c  -Os -pipe -march=native
      -frecord-gcc-switches -ggdb -Wall -g -DUSE_OPENSSL
      -DPUBKEY_DIR=\"/etc/wireless-regdb/pubkeys\" `pkg-config --cflags
      openssl` -DCONFIG_LIBNL30 `pkg-config --cflags libnl-3.0` -o
      print-regdom.o print-regdom.c
      x86_64-pc-linux-gnu-gcc -c  -Os -pipe -march=native
      -frecord-gcc-switches -ggdb -Wall -g -DUSE_OPENSSL
      -DPUBKEY_DIR=\"/etc/wireless-regdb/pubkeys\" `pkg-config --cflags
      openssl` -DCONFIG_LIBNL30 `pkg-config --cflags libnl-3.0` -o regdbdump.o
      regdbdump.c
      x86_64-pc-linux-gnu-gcc -c  -Os -pipe -march=native
      -frecord-gcc-switches -ggdb -Wall -g -DUSE_OPENSSL
      -DPUBKEY_DIR=\"/etc/wireless-regdb/pubkeys\" `pkg-config --cflags
      openssl` -DCONFIG_LIBNL30 `pkg-config --cflags libnl-3.0` -o reglib.o
      reglib.c
      reglib.c: In function ‘country2rd’:
      reglib.c:213:2: warning: implicit declaration of function ‘memset’
      [-Wimplicit-function-declaration]
      reglib.c:213:2: warning: incompatible implicit declaration of built-in
      function ‘memset’ [enabled by default]
      reglib.c: In function ‘reglib_get_rd_alpha2’:
      reglib.c:344:3: warning: implicit declaration of function ‘memcmp’
      [-Wimplicit-function-declaration]
      x86_64-pc-linux-gnu-gcc -Os -pipe -march=native -frecord-gcc-switches
      -ggdb -Wall -g -DUSE_OPENSSL
      -DPUBKEY_DIR=\"/etc/wireless-regdb/pubkeys\" `pkg-config --cflags
      openssl` -DCONFIG_LIBNL30 `pkg-config --cflags libnl-3.0` -Wl,-O1
      -Wl,--as-needed -Wl,--hash-style=gnu -o crda reglib.o crda.o `pkg-config
      --libs openssl` -lnl-genl-3 -lnl-3   `pkg-config --libs libnl-3.0`
      x86_64-pc-linux-gnu-gcc -Os -pipe -march=native -frecord-gcc-switches
      -ggdb -Wall -g -DUSE_OPENSSL
      -DPUBKEY_DIR=\"/etc/wireless-regdb/pubkeys\" `pkg-config --cflags
      openssl` -DCONFIG_LIBNL30 `pkg-config --cflags libnl-3.0` -Wl,-O1
      -Wl,--as-needed -Wl,--hash-style=gnu -o intersect reglib.o intersect.o
      print-regdom.o `pkg-config --libs openssl`
      x86_64-pc-linux-gnu-gcc -Os -pipe -march=native -frecord-gcc-switches
      -ggdb -Wall -g -DUSE_OPENSSL
      -DPUBKEY_DIR=\"/etc/wireless-regdb/pubkeys\" `pkg-config --cflags
      openssl` -DCONFIG_LIBNL30 `pkg-config --cflags libnl-3.0` -Wl,-O1
      -Wl,--as-needed -Wl,--hash-style=gnu -o regdbdump reglib.o regdbdump.o
      print-regdom.o `pkg-config --libs openssl`
      Reported-by: 's avatarRichard Farina <sidhayn@gmail.com>
      Signed-off-by: 's avatarLuis R. Rodriguez <mcgrof@do-not-panic.com>
      6a7fd50c
  9. 19 Jan, 2012 5 commits
  10. 18 Jan, 2012 2 commits
    • Luis R. Rodriguez's avatar
      crda: add a reglib iterator reglib_for_each_country() · ebcbfcf4
      Luis R. Rodriguez authored
      To allow for a simple library on reglib.c we want to enable
      an iterator over the regulatory database that does not have
      to lock the file, or pass references to the file. We instead
      add an iterator reglib_get_country_idx() which will use a
      new reglib_get_country_idx(), that does an O(n) search for
      each new regulatory domain it needs to read.
      
      The trade off here is to allow for a simple reglib.c implementation
      at the cost that upon each iteration reglib_get_country_idx()
      we will will be opening the regdb, and verifying the db signature.
      Given that the only user of this iterator is regdbdump though and
      that this is used for debugging for now this is trade off I am
      willing to live with.
      
      Systems that want to use the regdb as a database for fine tuning
      radio parameters dynamically and reading this file very *often*
      (seconds, minutes, who knows what the future holds) may want to
      consider a slight optimization of exporting the direct mmap()
      through the library but we are I think light years away from that.
      Signed-off-by: 's avatarLuis R. Rodriguez <mcgrof@qca.qualcomm.com>
      ebcbfcf4
    • Luis R. Rodriguez's avatar
      crda: move country2rd() and its helper to reglib.c · 0d421c28
      Luis R. Rodriguez authored
      Start cleaning the way we deal with reglib.c as the goal
      is to make that stuff a library to be shared first in
      userspace with the regulatory simulator [0]. We start
      off by moving country2rd() and its helper over to
      reglib.c.
      
      [0] git://github.com/mcgrof/regsim.gitSigned-off-by: 's avatarLuis R. Rodriguez <mcgrof@frijolero.org>
      0d421c28
  11. 15 Nov, 2011 1 commit
  12. 25 Jan, 2010 2 commits
    • Luis R. Rodriguez's avatar
      Space fix · 52300e7e
      Luis R. Rodriguez authored
      Signed-off-by: 's avatarLuis R. Rodriguez <lrodriguez@atheros.com>
      52300e7e
    • Paul Fertser's avatar
      Implement runtime loading of RSA public keys · 7429427a
      Paul Fertser authored
      This patch allows crda to load and use additional keys from a
      pre-configured location for the database signature verification. This
      provides a convenient way for distro maintainers and card manufacturers to
      supply a custom regulatory database along with their public keys, without
      the need to recompile crda.
      
      Implemented for USE_OPENSSL=1 case only because libgcrypt lacks PEM parser.
      
      Default location for public keys in PEM format is
      /etc/wireless-regdb/pubkeys and can be changed by specifying
      RUNTIME_PUBKEY_DIR at the make command line.
      Signed-off-by: 's avatarPaul Fertser <fercerpav@gmail.com>
      7429427a
  13. 17 Apr, 2009 1 commit
  14. 01 Dec, 2008 3 commits