Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

Commit

Permalink
remove unused option --keep
Browse files Browse the repository at this point in the history
1. remove --keep option
2. update README

Signed-off-by: Leon Huayra <hffilwlqm@gmail.com>
  • Loading branch information
Asphaltt committed Dec 11, 2021
1 parent dc8b5b7 commit 95cff15
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 12 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ Flags:
--icmpid uint16 trace icmp id
-H, --ipaddr string ip address
--iptables output iptables path
--keep keep trace packet all lifetime (DEPRECATED: not implemented yet)
-N, --netns uint32 trace this Network Namespace only
-N, --netns uint32 trace this netns inode only
--noroute do not output route path
-p, --pid uint32 trace this PID only
-P, --port uint16 udp or tcp port
Expand Down
6 changes: 1 addition & 5 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ type Config struct {
CallStack bool
Iptables bool
NoRoute bool
Keep bool
Time bool
Timestamp bool
Gops string
Expand All @@ -38,17 +37,14 @@ func init() {
fs.Uint64VarP(&cfg.CatchCount, "catch-count", "c", 1000, "catch and print count")
fs.Uint16VarP(&cfg.Port, "port", "P", 0, "udp or tcp port")
fs.Uint32VarP(&cfg.Pid, "pid", "p", 0, "trace this PID only")
fs.Uint32VarP(&cfg.NetNS, "netns", "N", 0, "trace this Network Namespace only")
fs.Uint32VarP(&cfg.NetNS, "netns", "N", 0, "trace this netns inode only")
fs.BoolVar(&cfg.DropStack, "dropstack", false, "output kernel stack trace when drop packet")
fs.BoolVar(&cfg.CallStack, "callstack", false, "output kernel stack trace")
fs.BoolVar(&cfg.Iptables, "iptables", false, "output iptables path")
fs.BoolVar(&cfg.NoRoute, "noroute", false, "do not output route path")
fs.BoolVar(&cfg.Keep, "keep", false, "keep trace packet all lifetime")
fs.BoolVarP(&cfg.Time, "time", "T", true, "show HH:MM:SS timestamp")
fs.BoolVarP(&cfg.Timestamp, "timestamp", "t", false, "show timestamp in seconds at us resolution")
fs.StringVar(&cfg.Gops, "gops", "", "gops address")

fs.Lookup("keep").Deprecated = "not implemented yet"
}

func (c *Config) parse() error {
Expand Down
3 changes: 1 addition & 2 deletions ebpf.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ type BpfConfig struct {
IcmpID uint16
DropStack uint8
CallStack uint8
Keep uint8
Proto uint8
pad uint8
}

const sizeOfBpfConfig = int(unsafe.Sizeof(BpfConfig{}))
Expand Down Expand Up @@ -127,7 +127,6 @@ func (p *bpfProgram) storeConfig() error {
IcmpID: (cfg.IcmpID >> 8) & (cfg.IcmpID << 8),
DropStack: bool2uint8(cfg.DropStack),
CallStack: bool2uint8(cfg.CallStack),
Keep: bool2uint8(cfg.Keep),
Proto: cfg.proto,
}

Expand Down
6 changes: 3 additions & 3 deletions ebpf/headers/skbtracer.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ struct config {
u16 icmpid;
u8 dropstack;
u8 callstack;
u8 keep;
u8 proto;
u8 pad;
};

BPF_MAP_DEF(skbtracer_cfg) = {
Expand Down Expand Up @@ -478,8 +478,8 @@ INLINE bool filter_netns(struct config *cfg, struct sk_buff *skb) {
}

INLINE bool filter_pid(struct config *cfg) {
u32 tgid = bpf_get_current_pid_tgid() >> 32;
return cfg->pid != 0 && cfg->pid != tgid;
u32 pid = bpf_get_current_pid_tgid() >> 32;
return cfg->pid != 0 && cfg->pid != pid;
}

INLINE bool filter_dropstack(struct config *cfg) {
Expand Down

0 comments on commit 95cff15

Please sign in to comment.