Skip to content

Commit

Permalink
fix no args on pktgen on module 2.75
Browse files Browse the repository at this point in the history
Signed-off-by: junka <[email protected]>
  • Loading branch information
junka committed Aug 6, 2024
1 parent 66aeb3f commit 5cba21b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
17 changes: 15 additions & 2 deletions pktperf/pktgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,19 @@ def __init__(self, args) -> None:
self.inner_smac_count = 0
self.microburst = args.microburst
self.imixweight = args.imix
else:
self.tun_vni = None
self.tun_udpport = None
self.tun_dst_min = None
self.tun_dst_max = None
self.tun_src_min = None
self.tun_src_max = None
self.inner_dmac = None
self.inner_smac = None
self.inner_dmac_count = 0
self.inner_smac_count = 0
self.microburst = None
self.imixweight = None
self.tcp = None
self.mode = None
self.rxq = []
Expand Down Expand Up @@ -666,7 +679,7 @@ def result_transient(self, need_init, core_id, fp_dev, print_cb):
pps, bps = pkt_sar.get_stats()
print_cb(
# pylint: disable=line-too-long
f"Core{core_id:3d} {direction} {pkt:18d} pkts: {pps:18f} pps {bps:18f} bps {byt:6d} bytes"
f"Core{core_id:3d} {direction} {pkt:18d} pkts: {pps:18.2f} pps {bps:18.2f} bps {byt:6d} bytes"
)

return pkt, pps, bps, byt
Expand Down Expand Up @@ -699,7 +712,7 @@ def result(self, last, print_cb) -> int:
total_bytes += sg_bytes
print_cb(
# pylint: disable=line-too-long
f"Total TX {total_pkts:18d} pkts: {total_pps:18d} pps {total_bps:18d} bps {total_bytes:6d} bytes"
f"Total TX {total_pkts:18d} pkts: {total_pps:18.2f} pps {total_bps:18.2f} bps {total_bytes:6d} bytes"
)

total_pkts = 0
Expand Down
7 changes: 5 additions & 2 deletions pktperf/pktperf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
parser = argparse.ArgumentParser(
description=f"pktgen python scripts {modinfo_check()}", epilog="\n"
)
parser.add_argument("-i", "--interface", help="output interface/device", required=False)
parser.add_argument("-i", "--interface", help="output interface/device", required=True)
parser.add_argument("-s", "--size", help="packet size", default=60, required=False)
parser.add_argument(
"-d",
Expand Down Expand Up @@ -130,6 +130,9 @@ def ui_func(pktgen, event):
def main():
"""main function entry"""
args = parser.parse_args()
if os.path.exists(f"/sys/class/net/{args.interface}") is False:
print(f"{args.interface} is not a valid interface")
return
pktgen = Pktgen(args)

event = Event()
Expand All @@ -152,7 +155,7 @@ def sig_exit(_sig, _frame):
signal.signal(signal.SIGINT, sig_exit)
signal.signal(signal.SIGALRM, sig_exit)

if int(args.timeout) > 0:
if modinfo_check() == "3.0" and int(args.timeout) > 0:
signal.alarm(int(args.timeout))
pktgen.config_queue()
tui.start()
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "pktperf"
version = "0.5.7"
version = "0.5.8"
authors = [
{ name="junka", email="[email protected]" },
]
Expand All @@ -26,4 +26,4 @@ pktperf = "pktperf.pktperf:main"

[project.urls]
"Homepage" = "https://github.com/junka/pktperf"
"Bug Tracker" = "https://github.com/junka/pktperf/issues"
"Bug Tracker" = "https://github.com/junka/pktperf/issues"
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def run(self):

setup(
name= 'pktperf',
version = "0.5.7",
version = "0.5.8",
has_ext_modules=lambda: True,
cmdclass={"install": CustomInstall},
platforms=["manylinux2014_x86_64"],
Expand Down

0 comments on commit 5cba21b

Please sign in to comment.