Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools/tcpcong: Reduce code redundancy #5122

Merged
merged 1 commit into from
Oct 21, 2024
Merged

Conversation

kknjh
Copy link

@kknjh kknjh commented Oct 13, 2024

1: Ports that do not meet the conditions in function "entry_state_update_func" will not be stored in the "start_ipv4" or "start_ipv6", and the "ret_state_update_func" function will not obtain values, so there is no need to perform port filtering again.

2: Sock_store can be directly deleted in function "ret_func".

1: Ports that do not meet the conditions in function
"entry_state_update_func" will not be stored in the "start_ipv4" or "start_ipv6",
and the "ret_state_update_func" function will not obtain values,
so there is no need to perform port filtering again.

2: Sock_store can be directly deleted in function "ret_func".

Signed-off-by: Feng Yang <[email protected]>
@@ -274,7 +265,7 @@
}
start_ipv6.delete(&key);
}
SOCK_STORE_DEL
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about the following prog?

KRETFUNC_PROBE(tcp_fastretrans_alert, struct sock *sk)
{
    return ret_state_update_func(sk);
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if is_support_kfunc:
    bpf_text += kfunc_program
    bpf_text = bpf_text.replace('SOCK_STORE_DEF', '')
    bpf_text = bpf_text.replace('SOCK_STORE_ADD', '')
    bpf_text = bpf_text.replace('SOCK_STORE_DEL', '')
else:
    bpf_text += kprobe_program
    bpf_text = bpf_text.replace('SOCK_STORE_DEF',
                   'BPF_HASH(sock_store, process_key_t, struct sock *);')
    bpf_text = bpf_text.replace('SOCK_STORE_ADD',
                   'sock_store.update(&key, &sk);')
    bpf_text = bpf_text.replace('SOCK_STORE_DEL',
                   'sock_store.delete(&key);')

It does not use SOCK_STORE, so it does not affect

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I see. Indeed this is the case.

@yonghong-song yonghong-song merged commit 0d5dcf4 into iovisor:master Oct 21, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants