Lines Matching +full:0 +full:- +full:9 +full:a +full:- +full:fa +full:- +full:f

2 # SPDX-License-Identifier: GPL-2.0
66 UINT32_MAX = 0xFFFFFFFF
74 tot = 0
76 if str2.find(char) != -1:
83 tot = 0
85 if str2.find(char) == -1:
91 def intparse(statestr, defmask="0xffffffff"):
97 if firstnum[-1] == "/":
98 firstnum = firstnum[:-1]
99 k = int(firstnum, 0)
106 m = int(secondnum, 0)
112 bitResult = 0
113 maskResult = 0
115 if len(flag_str) == 0:
118 if flag_str[0].isdigit():
119 idx = 0
125 bitResult = int(digits, 0)
126 maskResult = int(digits, 0)
128 while len(flag_str) > 0 and (flag_str[0] == "+" or flag_str[0] == "-"):
129 if flag_str[0] == "+":
131 elif flag_str[0] == "-":
136 flag_len = 0
139 and flag_str[flag_len] != "-"
145 flag = flag_str[0:flag_len]
167 "new": 1 << 0,
199 ip = mask = 0
201 mask = 0xFFFFFFFF
203 mask = (0xFFFFFFFF << (32 - int(mask))) & 0xFFFFFFFF
211 ip = mask = 0
224 return 0, 0
226 return int(value, 0), pow(2, size) - 1
228 return int(value, 0), int(mask, 0)
240 block_str = block_str[len(m.group(0)) :]
265 if str_skiplen == 0:
268 str_skiplen = 0
275 data = m.group(0)
277 data = convert(m.group(0))
279 str_skipped = str_skipped[len(m.group(0)) :]
281 if str_skipped[0] == "/":
289 """Parses the given action string and returns a list of netlink
290 attributes based on a list of attribute descriptions.
292 Each element in the attribute description list is a tuple such as:
297 parse_func: is a callable accepting a string and returning either
298 a single object (the parsed attribute value) or a tuple of
301 Returns a list of attributes and the remaining string.
309 delim = actstr[0]
325 if not actstr or actstr[0] != ")":
336 while actstr and actstr[0] != ")" and attr_desc:
350 if actstr[0] != ")":
359 # We need a custom header rather than just being able to rely on
442 args.append("sample={:.2f}%".format(
513 print_str += "XXX-unknown-nat"
524 print_str += "-%s," % str(
564 print_str += "emask=0x%X," % self.get_attr(
592 for f in self.get_attr("OVS_USERSPACE_ATTR_USERDATA"):
593 print_str += "%x." % f
619 if field[1] == "none" or self.get_attr(field[0]) is None:
624 if field[0] == "OVS_ACTION_ATTR_OUTPUT":
625 print_str += "%d" % int(self.get_attr(field[0]))
626 elif field[0] == "OVS_ACTION_ATTR_RECIRC":
627 print_str += "recirc(0x%x)" % int(self.get_attr(field[0]))
628 elif field[0] == "OVS_ACTION_ATTR_TRUNC":
629 print_str += "trunc(%d)" % int(self.get_attr(field[0]))
630 elif field[0] == "OVS_ACTION_ATTR_DROP":
631 print_str += "drop(%d)" % int(self.get_attr(field[0]))
632 elif field[0] == "OVS_ACTION_ATTR_CT_CLEAR":
634 elif field[0] == "OVS_ACTION_ATTR_POP_VLAN":
636 elif field[0] == "OVS_ACTION_ATTR_POP_ETH":
638 elif field[0] == "OVS_ACTION_ATTR_POP_NSH":
640 elif field[0] == "OVS_ACTION_ATTR_POP_MPLS":
643 datum = self.get_attr(field[0])
644 if field[0] == "OVS_ACTION_ATTR_CLONE":
648 elif field[0] == "OVS_ACTION_ATTR_SET" or \
649 field[0] == "OVS_ACTION_ATTR_SET_MASKED":
653 if field[0] == "OVS_ACTION_ATTR_SET_MASKED":
655 field = datum[0]
664 print_str += "{ATTR: %s not decoded}" % field[0]
670 while len(actstr) != 0:
672 parencount = 0
683 r"([0-9]+)",
684 lambda x: int(x, 0),
694 return (totallen - len(actstr))
698 actstr, None, r"(\d+)", lambda x: int(x), False, "0"
706 r"([0-9a-fA-Fx]+)",
707 lambda x: int(x, 0),
709 0,
723 if parse_starts_block(actstr, flat_act[0], False):
724 actstr = actstr[len(flat_act[0]):]
770 if actstr.startswith(scan[0]):
771 actstr = actstr[len(scan[0]) :]
773 if actstr[0] != "=":
777 datum = scan[2](actstr[:pos], 0)
783 # it seems strange to put this here, but nat() is a complex
784 # sub-action and this lets it sit anywhere in the ct() action
801 actstr, "=", r"([0-9a-fA-F\.]+)", str, False
804 actstr, "-", r"([0-9a-fA-F\.]+)", str, False
811 actstr, "-", r"(\d+)", int, False
839 if actstr.startswith(natscan[0]):
840 actstr = actstr[len(natscan[0]) :]
873 r"([0-9]+)",
882 while parencount > 0:
883 parencount -= 1
885 if len(actstr) and actstr[0] != ")":
889 if len(actstr) and actstr[0] == ")":
890 return (totallen - len(actstr))
897 return (totallen - len(actstr))
945 ("src", "src", "%d", lambda x: int(x) if x else 0,
947 ("dst", "dst", "%d", lambda x: int(x) if x else 0,
983 for f in self.fields_map:
984 if flowstr.startswith(f[1]):
986 # something like 'field.' where '.' is a
988 flowstr = flowstr[len(f[1]) + 1 :]
989 splitchar = 0
999 if len(f) > 4:
1000 k[f[0]], m[f[0]] = f[4](data)
1002 k[f[0]] = f[3](data)
1003 m[f[0]] = f[3](data)
1006 if len(flowstr) == 0:
1016 for f in self.fields_map:
1020 outstr += "%s=" % f[0]
1021 if isinstance(f[2], str):
1022 outstr += f[2] % self[f[1]]
1024 outstr += f[2](self[f[1]])
1026 elif more or f[3](masked[f[1]]) != 0:
1027 outstr += "%s=" % f[0]
1028 if isinstance(f[2], str):
1029 outstr += f[2] % self[f[1]]
1031 outstr += f[2](self[f[1]])
1033 if isinstance(f[2], str):
1034 outstr += f[2] % masked[f[1]]
1036 outstr += f[2](masked[f[1]])
1107 ("proto", "proto", "%d", lambda x: int(x) if x else 0,
1109 ("tos", "tos", "%d", lambda x: int(x) if x else 0,
1111 ("ttl", "ttl", "%d", lambda x: int(x) if x else 0,
1113 ("frag", "frag", "%d", lambda x: int(x) if x else 0,
1151 lambda x: ipaddress.IPv6Address(x).packed if x else 0,
1158 lambda x: ipaddress.IPv6Address(x).packed if x else 0,
1161 ("label", "label", "%d", lambda x: int(x) if x else 0),
1162 ("proto", "proto", "%d", lambda x: int(x) if x else 0),
1163 ("tclass", "tclass", "%d", lambda x: int(x) if x else 0),
1164 ("hlimit", "hlimit", "%d", lambda x: int(x) if x else 0),
1165 ("frag", "frag", "%d", lambda x: int(x) if x else 0),
1250 ("type", "type", "%d", lambda x: int(x) if x else 0),
1251 ("code", "code", "%d", lambda x: int(x) if x else 0),
1316 ("op", "op", "%d", lambda x: int(x) if x else 0),
1516 0xffffffffffffffff, None, None),
1518 ("src=", r"([0-9a-fA-F\.]+)", str,
1521 ("dst=", r"([0-9a-fA-F\.]+)", str,
1525 ("ipv6_src=", r"([0-9a-fA-F:]+)", str,
1528 ("ipv6_dst=", r"([0-9a-fA-F:]+)", str,
1532 ("tos=", r"(\d+)", int, "OVS_TUNNEL_KEY_ATTR_TOS", 255, 0,
1534 ("ttl=", r"(\d+)", int, "OVS_TUNNEL_KEY_ATTR_TTL", 255, 0,
1538 65535, 0, None),
1540 65535, 0, None),
1570 if k["attrs"][0][0] != "OVS_TUNNEL_KEY_ATTR_ID":
1571 raise ValueError("Needs a tunid set")
1600 if k[0] == "OVS_TUNNEL_KEY_ATTR_ID":
1602 elif k[0] == "OVS_TUNNEL_KEY_ATTR_IPV4_SRC":
1604 elif k[0] == "OVS_TUNNEL_KEY_ATTR_IPV4_DST":
1606 elif k[0] == "OVS_TUNNEL_KEY_ATTR_IPV6_SRC":
1608 elif k[0] == "OVS_TUNNEL_KEY_ATTR_IPV6_DST":
1610 elif k[0] == "OVS_TUNNEL_KEY_ATTR_TOS":
1612 elif k[0] == "OVS_TUNNEL_KEY_ATTR_TTL":
1614 elif k[0] == "OVS_TUNNEL_KEY_ATTR_TP_SRC":
1616 elif k[0] == "OVS_TUNNEL_KEY_ATTR_TP_DST":
1618 elif k[0] == "OVS_TUNNEL_KEY_ATTR_DONT_FRAGMENT":
1621 elif k[0] == "OVS_TUNNEL_KEY_ATTR_CSUM":
1624 elif k[0] == "OVS_TUNNEL_KEY_ATTR_OAM":
1658 lambda x: intparse(x, "0xffff"),
1708 mask["attrs"].append([field[0], m])
1709 self["attrs"].append([field[0], k])
1736 "0x%08X",
1743 "0x%08X",
1757 "0x%04x",
1764 "0x%04x",
1771 "0x%08x",
1800 "0x%04x",
1801 lambda x: int(x) == 0xFFFF,
1811 "0x%04x",
1821 v = self.get_attr(field[0])
1823 m = None if mask is None else mask.get_attr(field[0])
1832 elif more or m != 0:
1927 def info(self, dpname, ifindex=0):
1931 msg["reserved"] = 0
1939 reply = reply[0]
1956 msg["version"] = int(versionStr.split(":")[0], 0)
1957 msg["reserved"] = 0
1958 msg["dpifindex"] = 0
1961 dpfeatures = 0
1962 if versionStr is not None and versionStr.find(":") != -1:
1963 dpfeatures = int(versionStr.split(":")[1], 0)
1965 if versionStr is None or versionStr.find(":") == -1:
1976 msg["attrs"].append(["OVS_DP_ATTR_UPCALL_PID", [0]])
1982 reply = reply[0]
1995 msg["reserved"] = 0
1996 msg["dpifindex"] = 0
2003 reply = reply[0]
2084 def info(self, vport_name, dpifindex=0, portno=None):
2089 msg["reserved"] = 0
2101 reply = reply[0]
2114 msg["reserved"] = 0
2127 if ptype == tnl[0]:
2143 if tnl[0] == "geneve":
2144 ipr.link("add", ifname=vport_ifname, kind=tnl[0],
2148 elif tnl[0] == "vxlan":
2149 ipr.link("add", ifname=vport_ifname, kind=tnl[0],
2150 vxlan_learning=0, vxlan_collect_metadata=1,
2159 reply = reply[0]
2172 msg["reserved"] = 0
2187 reply = reply[0]
2197 msg["reserved"] = 0
2205 reply = reply[0]
2244 "ufid:{:08x}-{:04x}-{:04x}-{:04x}-{:04x}{:08x}".format(
2245 ufid[0],
2247 ufid[1] & 0xFFFF,
2249 ufid[2] & 0,
2279 print_str += " packets:0, bytes:0,"
2293 used_time = (cur_time_sec * 1000) - used_time
2300 or len(actsmsg["attrs"]) == 0
2308 def parse(self, flowstr, actstr, dpidx=0):
2309 OVS_UFID_F_OMIT_KEY = 1 << 0
2313 self["cmd"] = 0
2314 self["version"] = 0
2315 self["reserved"] = 0
2316 self["dpifindex"] = 0
2332 uuidRawObj[0],
2336 | uuidRawObj[5] & (0xFF << 32) >> 32,
2337 uuidRawObj[5] & (0xFFFFFFFF),
2358 a = ovsactions()
2359 a.parse(actstr)
2360 self["attrs"].append(["OVS_FLOW_ATTR_ACTIONS", a])
2369 Send a new flow message to the kernel.
2371 dpifindex should be a valid datapath obtained by calling
2374 flowmsg is a flow object obtained by calling a dpparse
2379 flowmsg["reserved"] = 0
2388 reply = reply[0]
2396 Send a del message to the kernel that will drop all flows.
2398 dpifindex should be a valid datapath obtained by calling
2405 flowmsg["reserved"] = 0
2414 reply = reply[0]
2422 Returns a list of messages containing flows.
2424 dpifindex should be a valid datapath obtained by calling
2427 flowpsec is a string which represents a flow in the dpctl
2434 msg["reserved"] = 0
2502 if attr == "PSAMPLE_ATTR_DATA" and len(value) > 0:
2509 PSAMPLE_CMD_SAMPLE = 0
2546 avg = (megaflow_stats["mask_hit"] / pkts) if pkts != 0 else 0.0
2548 " masks: hit:%d total:%d hit/pkt:%f"
2552 print(" masks-cache: size:%d" % masks_cache_size)
2555 print(" features: 0x%X" % user_features)
2566 opts += " tnl-dport:%s" % socket.ntohs(dpo)
2584 if int(prverscheck[0]) == 0 and int(prverscheck[1]) < 6:
2586 sys.exit(0)
2590 "-v",
2591 "--verbose",
2594 default=0,
2603 adddpcmd = subparsers.add_parser("add-dp")
2606 "-u",
2607 "--upcall",
2609 help="Leave open a reader for upcalls",
2612 "-V",
2613 "--versioning",
2615 help="Specify a custom version / feature string",
2618 deldpcmd = subparsers.add_parser("del-dp")
2621 addifcmd = subparsers.add_parser("add-if")
2625 "-u",
2626 "--upcall",
2628 help="Leave open a reader for upcalls",
2631 "-t",
2632 "--ptype",
2639 "-p",
2640 "--dport",
2642 default=0,
2643 help="Destination port (0 for default)"
2646 "-l",
2647 "--lwt",
2652 delifcmd = subparsers.add_parser("del-if")
2655 delifcmd.add_argument("-d",
2656 "--dellink",
2660 dumpflcmd = subparsers.add_parser("dump-flows")
2663 addflcmd = subparsers.add_parser("add-flow")
2668 delfscmd = subparsers.add_parser("del-flows")
2671 subparsers.add_parser("psample-events")
2675 if args.verbose > 0:
2687 if args.subcommand == "psample-events":
2695 rep = ovsdp.info(iface.ifname, 0)
2697 rep = ovsdp.info(iface.ifname, 0)
2719 rep = ovsdp.info(args.dpname, 0)
2736 rep = ovsdp.info(args.dpname, 0)
2748 ipr.link("del", index=ipr.link_lookup(ifname=args.delif)[0])
2750 rep = ovsdp.info(args.dumpdp, 0)
2756 print(flow.dpstr(True if args.verbose > 0 else False))
2758 rep = ovsdp.info(args.flbr, 0)
2766 rep = ovsdp.info(args.flsbr, 0)
2771 return 0