| 1 | |
| 2 |
|
| 3 | import sys
|
| 4 | from pathlib import Path
|
| 5 | from .consts import KSRC, KSFT_DIR
|
| 6 | from .ksft import ksft_pr, ktap_result
|
| 7 |
|
| 8 | |
| 9 | try:
|
| 10 | if (KSFT_DIR / "kselftest-list.txt").exists():
|
| 11 | |
| 12 | tools_full_path = KSFT_DIR
|
| 13 | SPEC_PATH = KSFT_DIR / "net/lib/specs"
|
| 14 |
|
| 15 | sys.path.append(tools_full_path.as_posix())
|
| 16 | from net.lib.ynl.pyynl.lib import YnlFamily, NlError, NlPolicy, Netlink
|
| 17 | else:
|
| 18 | |
| 19 | tools_full_path = KSRC / "tools"
|
| 20 | SPEC_PATH = KSRC / "Documentation/netlink/specs"
|
| 21 |
|
| 22 | sys.path.append(tools_full_path.as_posix())
|
| 23 | from net.ynl.pyynl.lib import YnlFamily, NlError, NlPolicy, Netlink
|
| 24 | except ModuleNotFoundError as e:
|
| 25 | ksft_pr("Failed importing `ynl` library from kernel sources")
|
| 26 | ksft_pr(str(e))
|
| 27 | ktap_result(True, comment="SKIP")
|
| 28 | sys.exit(4)
|
| 29 |
|
| 30 | __all__ = [
|
| 31 | "NlError", "NlPolicy", "Netlink", "YnlFamily", "SPEC_PATH",
|
| 32 | "EthtoolFamily", "RtnlFamily", "RtnlAddrFamily", "RtnlRouteFamily",
|
| 33 | "NetdevFamily", "NetshaperFamily", "NlctrlFamily", "DevlinkFamily",
|
| 34 | "PSPFamily",
|
| 35 | ]
|
| 36 |
|
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | class EthtoolFamily(YnlFamily):
|
| 42 | def __init__(self, recv_size=0):
|
| 43 | super().__init__((SPEC_PATH / Path('ethtool.yaml')).as_posix(),
|
| 44 | schema='', recv_size=recv_size)
|
| 45 |
|
| 46 |
|
| 47 | class RtnlFamily(YnlFamily):
|
| 48 | def __init__(self, recv_size=0):
|
| 49 | super().__init__((SPEC_PATH / Path('rt-link.yaml')).as_posix(),
|
| 50 | schema='', recv_size=recv_size)
|
| 51 |
|
| 52 | class RtnlAddrFamily(YnlFamily):
|
| 53 | def __init__(self, recv_size=0):
|
| 54 | super().__init__((SPEC_PATH / Path('rt-addr.yaml')).as_posix(),
|
| 55 | schema='', recv_size=recv_size)
|
| 56 |
|
| 57 | class RtnlRouteFamily(YnlFamily):
|
| 58 | def __init__(self, recv_size=0):
|
| 59 | super().__init__((SPEC_PATH / Path('rt-route.yaml')).as_posix(),
|
| 60 | schema='', recv_size=recv_size)
|
| 61 |
|
| 62 | class NetdevFamily(YnlFamily):
|
| 63 | def __init__(self, recv_size=0):
|
| 64 | super().__init__((SPEC_PATH / Path('netdev.yaml')).as_posix(),
|
| 65 | schema='', recv_size=recv_size)
|
| 66 |
|
| 67 | class NetshaperFamily(YnlFamily):
|
| 68 | def __init__(self, recv_size=0):
|
| 69 | super().__init__((SPEC_PATH / Path('net_shaper.yaml')).as_posix(),
|
| 70 | schema='', recv_size=recv_size)
|
| 71 |
|
| 72 |
|
| 73 | class NlctrlFamily(YnlFamily):
|
| 74 | def __init__(self, recv_size=0):
|
| 75 | super().__init__((SPEC_PATH / Path('nlctrl.yaml')).as_posix(),
|
| 76 | schema='', recv_size=recv_size)
|
| 77 |
|
| 78 |
|
| 79 | class DevlinkFamily(YnlFamily):
|
| 80 | def __init__(self, recv_size=0):
|
| 81 | super().__init__((SPEC_PATH / Path('devlink.yaml')).as_posix(),
|
| 82 | schema='', recv_size=recv_size)
|
| 83 |
|
| 84 | class PSPFamily(YnlFamily):
|
| 85 | def __init__(self, recv_size=0):
|
| 86 | super().__init__((SPEC_PATH / Path('psp.yaml')).as_posix(),
|
| 87 | schema='', recv_size=recv_size)
|