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]") { ...@@ -44,10 +44,8 @@ TEST_CASE("binary resolution with `which`", "[c_api]") {
} }
static void _test_ksym(const char *sym, uint64_t addr, void *_) { static void _test_ksym(const char *sym, uint64_t addr, void *_) {
if (!strcmp(sym, "startup_64")) { if (!strcmp(sym, "startup_64"))
REQUIRE(addr == 0xffffffff81000000ull); REQUIRE(addr != 0x0ull);
} else if (!strcmp(sym, "system_reset_pSeries"))
REQUIRE(addr == 0xc000000000000100ull);
} }
TEST_CASE("list all kernel symbols", "[c_api]") { TEST_CASE("list all kernel symbols", "[c_api]") {
......
...@@ -269,9 +269,9 @@ function TestClang:test_unop_probe_read() ...@@ -269,9 +269,9 @@ function TestClang:test_unop_probe_read()
local text = [[ local text = [[
#include <linux/blkdev.h> #include <linux/blkdev.h>
int trace_entry(struct pt_regs *ctx, struct request *req) { int trace_entry(struct pt_regs *ctx, struct request *req) {
if (!(req->bio->bi_rw & 1)) if (!(req->bio->bi_flags & 1))
return 1; return 1;
if (((req->bio->bi_rw))) if (((req->bio->bi_flags)))
return 1; return 1;
return 0; return 0;
} }
......
...@@ -284,9 +284,9 @@ int kprobe____kmalloc(struct pt_regs *ctx, size_t size) { ...@@ -284,9 +284,9 @@ int kprobe____kmalloc(struct pt_regs *ctx, size_t size) {
text = """ text = """
#include <linux/blkdev.h> #include <linux/blkdev.h>
int trace_entry(struct pt_regs *ctx, struct request *req) { int trace_entry(struct pt_regs *ctx, struct request *req) {
if (!(req->bio->bi_rw & 1)) if (!(req->bio->bi_flags & 1))
return 1; return 1;
if (((req->bio->bi_rw))) if (((req->bio->bi_flags)))
return 1; return 1;
return 0; return 0;
} }
......
...@@ -18,7 +18,7 @@ int on_packet(struct __sk_buff *skb) { ...@@ -18,7 +18,7 @@ int on_packet(struct __sk_buff *skb) {
u32 orig_dip = 0; u32 orig_dip = 0;
u32 orig_sip = 0; u32 orig_sip = 0;
struct IPLeaf *xleaf; struct IPLeaf xleaf = {};
ethernet: { ethernet: {
struct ethernet_t *ethernet = cursor_advance(cursor, sizeof(*ethernet)); struct ethernet_t *ethernet = cursor_advance(cursor, sizeof(*ethernet));
...@@ -44,11 +44,12 @@ int on_packet(struct __sk_buff *skb) { ...@@ -44,11 +44,12 @@ int on_packet(struct __sk_buff *skb) {
orig_dip = arp->tpa; orig_dip = arp->tpa;
orig_sip = arp->spa; orig_sip = arp->spa;
struct IPKey key = {.dip=orig_dip, .sip=orig_sip}; struct IPKey key = {.dip=orig_dip, .sip=orig_sip};
xleaf = xlate.lookup(&key); struct IPLeaf *xleafp = xlate.lookup(&key);
if (xleaf) { if (xleafp) {
arp->tpa = xleaf->xdip; xleaf = *xleafp;
arp->spa = xleaf->xsip; arp->tpa = xleaf.xdip;
lock_xadd(&xleaf->arp_xlated_pkts, 1); arp->spa = xleaf.xsip;
lock_xadd(&xleafp->arp_xlated_pkts, 1);
} }
goto EOP; goto EOP;
} }
...@@ -58,13 +59,14 @@ int on_packet(struct __sk_buff *skb) { ...@@ -58,13 +59,14 @@ int on_packet(struct __sk_buff *skb) {
orig_dip = ip->dst; orig_dip = ip->dst;
orig_sip = ip->src; orig_sip = ip->src;
struct IPKey key = {.dip=orig_dip, .sip=orig_sip}; struct IPKey key = {.dip=orig_dip, .sip=orig_sip};
xleaf = xlate.lookup(&key); struct IPLeaf *xleafp = xlate.lookup(&key);
if (xleaf) { if (xleafp) {
ip->dst = xleaf->xdip; xleaf = *xleafp;
incr_cksum_l3(&ip->hchecksum, orig_dip, xleaf->xdip); ip->dst = xleaf.xdip;
ip->src = xleaf->xsip; incr_cksum_l3(&ip->hchecksum, orig_dip, xleaf.xdip);
incr_cksum_l3(&ip->hchecksum, orig_sip, xleaf->xsip); ip->src = xleaf.xsip;
lock_xadd(&xleaf->ip_xlated_pkts, 1); incr_cksum_l3(&ip->hchecksum, orig_sip, xleaf.xsip);
lock_xadd(&xleafp->ip_xlated_pkts, 1);
} }
switch (ip->nextp) { switch (ip->nextp) {
case 6: goto tcp; case 6: goto tcp;
...@@ -75,18 +77,18 @@ int on_packet(struct __sk_buff *skb) { ...@@ -75,18 +77,18 @@ int on_packet(struct __sk_buff *skb) {
udp: { udp: {
struct udp_t *udp = cursor_advance(cursor, sizeof(*udp)); struct udp_t *udp = cursor_advance(cursor, sizeof(*udp));
if (xleaf) { if (xleaf.xdip) {
incr_cksum_l4(&udp->crc, orig_dip, xleaf->xdip, 1); incr_cksum_l4(&udp->crc, orig_dip, xleaf.xdip, 1);
incr_cksum_l4(&udp->crc, orig_sip, xleaf->xsip, 1); incr_cksum_l4(&udp->crc, orig_sip, xleaf.xsip, 1);
} }
goto EOP; goto EOP;
} }
tcp: { tcp: {
struct tcp_t *tcp = cursor_advance(cursor, sizeof(*tcp)); struct tcp_t *tcp = cursor_advance(cursor, sizeof(*tcp));
if (xleaf) { if (xleaf.xdip) {
incr_cksum_l4(&tcp->cksum, orig_dip, xleaf->xdip, 1); incr_cksum_l4(&tcp->cksum, orig_dip, xleaf.xdip, 1);
incr_cksum_l4(&tcp->cksum, orig_sip, xleaf->xsip, 1); incr_cksum_l4(&tcp->cksum, orig_sip, xleaf.xsip, 1);
} }
goto EOP; 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