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

return failure if rewriter cannot rewrite properly #2936

Merged
merged 1 commit into from
May 26, 2020
Merged

Conversation

yonghong-song
Copy link
Collaborator

Fix issue #537.

The bcc rewriter does not have enough information to do
proper rewriting from:

  #define PKT_LEN_ADD 1
  ip->tlen += PKT_LEN_ADD;

to

  bpf_dins_pkt(skb, (u64)ip+2, 0, 16, PKT_LEN_ADD);

So instead of generate incorrect code
which caused compilation error. Let return an error
earlier with helper comments so users know what to do.
With this patch, we will have

 /virtual/main.c:20:17: error: cannot have macro at the end of expresssion,
 workaround: put perentheses around macro "(MARCO)"
    ip->tlen += PKT_LEN_ADD;
                ^

Fix issue #537.

The bcc rewriter does not have enough information to do
proper rewriting from:
  #define PKT_LEN_ADD 1
  ip->tlen += PKT_LEN_ADD;
to
  bpf_dins_pkt(skb, (u64)ip+2, 0, 16, PKT_LEN_ADD);

So instead of generate incorrect code
which caused compilation error. Let return an error
earlier with helper comments so users know what to do.
With this patch, we will have
 /virtual/main.c:20:17: error: cannot have macro at the end of expresssion,
 workaround: put perentheses around macro "(MARCO)"
    ip->tlen += PKT_LEN_ADD;
                ^
@yonghong-song yonghong-song mentioned this pull request May 26, 2020
@yonghong-song yonghong-song merged commit 30d8975 into master May 26, 2020
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.

1 participant