Commit 81f7fb32 authored by 4ast's avatar 4ast Committed by GitHub

Merge pull request #817 from iovisor/clang_c_fixes

Fixup test errors in clang, c api
parents 0d5d25ea 35c7225f
......@@ -44,10 +44,8 @@ TEST_CASE("binary resolution with `which`", "[c_api]") {
}
static void _test_ksym(const char *sym, uint64_t addr, void *_) {
if (!strcmp(sym, "startup_64")) {
REQUIRE(addr == 0xffffffff81000000ull);
} else if (!strcmp(sym, "system_reset_pSeries"))
REQUIRE(addr == 0xc000000000000100ull);
if (!strcmp(sym, "startup_64"))
REQUIRE(addr != 0x0ull);
}
TEST_CASE("list all kernel symbols", "[c_api]") {
......
......@@ -269,9 +269,9 @@ function TestClang:test_unop_probe_read()
local text = [[
#include <linux/blkdev.h>
int trace_entry(struct pt_regs *ctx, struct request *req) {
if (!(req->bio->bi_rw & 1))
if (!(req->bio->bi_flags & 1))
return 1;
if (((req->bio->bi_rw)))
if (((req->bio->bi_flags)))
return 1;
return 0;
}
......
......@@ -284,9 +284,9 @@ int kprobe____kmalloc(struct pt_regs *ctx, size_t size) {
text = """
#include <linux/blkdev.h>
int trace_entry(struct pt_regs *ctx, struct request *req) {
if (!(req->bio->bi_rw & 1))
if (!(req->bio->bi_flags & 1))
return 1;
if (((req->bio->bi_rw)))
if (((req->bio->bi_flags)))
return 1;
return 0;
}
......
......@@ -18,7 +18,7 @@ int on_packet(struct __sk_buff *skb) {
u32 orig_dip = 0;
u32 orig_sip = 0;
struct IPLeaf *xleaf;
struct IPLeaf xleaf = {};
ethernet: {
struct ethernet_t *ethernet = cursor_advance(cursor, sizeof(*ethernet));
......@@ -44,11 +44,12 @@ int on_packet(struct __sk_buff *skb) {
orig_dip = arp->tpa;
orig_sip = arp->spa;
struct IPKey key = {.dip=orig_dip, .sip=orig_sip};
xleaf = xlate.lookup(&key);
if (xleaf) {
arp->tpa = xleaf->xdip;
arp->spa = xleaf->xsip;
lock_xadd(&xleaf->arp_xlated_pkts, 1);
struct IPLeaf *xleafp = xlate.lookup(&key);
if (xleafp) {
xleaf = *xleafp;
arp->tpa = xleaf.xdip;
arp->spa = xleaf.xsip;
lock_xadd(&xleafp->arp_xlated_pkts, 1);
}
goto EOP;
}
......@@ -58,13 +59,14 @@ int on_packet(struct __sk_buff *skb) {
orig_dip = ip->dst;
orig_sip = ip->src;
struct IPKey key = {.dip=orig_dip, .sip=orig_sip};
xleaf = xlate.lookup(&key);
if (xleaf) {
ip->dst = xleaf->xdip;
incr_cksum_l3(&ip->hchecksum, orig_dip, xleaf->xdip);
ip->src = xleaf->xsip;
incr_cksum_l3(&ip->hchecksum, orig_sip, xleaf->xsip);
lock_xadd(&xleaf->ip_xlated_pkts, 1);
struct IPLeaf *xleafp = xlate.lookup(&key);
if (xleafp) {
xleaf = *xleafp;
ip->dst = xleaf.xdip;
incr_cksum_l3(&ip->hchecksum, orig_dip, xleaf.xdip);
ip->src = xleaf.xsip;
incr_cksum_l3(&ip->hchecksum, orig_sip, xleaf.xsip);
lock_xadd(&xleafp->ip_xlated_pkts, 1);
}
switch (ip->nextp) {
case 6: goto tcp;
......@@ -75,18 +77,18 @@ int on_packet(struct __sk_buff *skb) {
udp: {
struct udp_t *udp = cursor_advance(cursor, sizeof(*udp));
if (xleaf) {
incr_cksum_l4(&udp->crc, orig_dip, xleaf->xdip, 1);
incr_cksum_l4(&udp->crc, orig_sip, xleaf->xsip, 1);
if (xleaf.xdip) {
incr_cksum_l4(&udp->crc, orig_dip, xleaf.xdip, 1);
incr_cksum_l4(&udp->crc, orig_sip, xleaf.xsip, 1);
}
goto EOP;
}
tcp: {
struct tcp_t *tcp = cursor_advance(cursor, sizeof(*tcp));
if (xleaf) {
incr_cksum_l4(&tcp->cksum, orig_dip, xleaf->xdip, 1);
incr_cksum_l4(&tcp->cksum, orig_sip, xleaf->xsip, 1);
if (xleaf.xdip) {
incr_cksum_l4(&tcp->cksum, orig_dip, xleaf.xdip, 1);
incr_cksum_l4(&tcp->cksum, orig_sip, xleaf.xsip, 1);
}
goto EOP;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment