-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Missing ')' #537
Comments
This is a rewriter deficiency. Workaround until this issue is fixed should be to do:
|
Hi @drzaeus77, there are also some issues when defines are used:
fails to compile with the following error:
A workaround is to enclose the define in parentheses:
PD: please ignore any possible verifier error on this example, I created it only to illustrate this bcc issue. |
Today I faced the error when both rewriter and macro are used. Master branch, ubuntu 19.10, kernel 5.3. I think this is an error, although the parentheses trick does work. #include <linux/if_ether.h>
#include <bcc/proto.h>
#include <uapi/linux/pkt_cls.h>
#define PKT_LEN_ADD 1
int mon_ingress(struct __sk_buff *skb) {
u8 *cursor = 0;
struct ethernet_t *eth = cursor_advance(cursor, sizeof(*eth));
if (eth->type != ETH_P_IP) {
return TC_ACT_OK;
}
struct ip_t *ip = cursor_advance(cursor, sizeof(*ip));
ip->tlen += PKT_LEN_ADD;
return TC_ACT_OK;
} and the error:
|
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; ^
The bcc does not have enough information to do rewrite. So let us explicitly warn user the issues instead of silently generating incorrect code. |
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 iovisor#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; ^
Hello again, this time with a real bug, I think.
Here is a sample program that is causing the error.
The text was updated successfully, but these errors were encountered: