comparison src/core/ngx_bpf.c @ 8722:7a07724256c2 quic

Core: fixed build with BPF on non-64bit platforms (ticket #2152).
author Vladimir Homutov <vl@nginx.com>
date Tue, 23 Mar 2021 10:58:18 +0300
parents d3747ba486e7
children
comparison
equal deleted inserted replaced
8721:85e60c064728 8722:7a07724256c2
43 char buf[NGX_BPF_LOGBUF_SIZE]; 43 char buf[NGX_BPF_LOGBUF_SIZE];
44 #endif 44 #endif
45 45
46 ngx_memzero(&attr, sizeof(union bpf_attr)); 46 ngx_memzero(&attr, sizeof(union bpf_attr));
47 47
48 attr.license = (uint64_t) program->license; 48 attr.license = (uintptr_t) program->license;
49 attr.prog_type = program->type; 49 attr.prog_type = program->type;
50 attr.insns = (uint64_t) program->ins; 50 attr.insns = (uintptr_t) program->ins;
51 attr.insn_cnt = program->nins; 51 attr.insn_cnt = program->nins;
52 52
53 #if (NGX_DEBUG) 53 #if (NGX_DEBUG)
54 /* for verifier errors */ 54 /* for verifier errors */
55 attr.log_buf = (uint64_t) buf; 55 attr.log_buf = (uintptr_t) buf;
56 attr.log_size = NGX_BPF_LOGBUF_SIZE; 56 attr.log_size = NGX_BPF_LOGBUF_SIZE;
57 attr.log_level = 1; 57 attr.log_level = 1;
58 #endif 58 #endif
59 59
60 fd = ngx_bpf(BPF_PROG_LOAD, &attr, sizeof(attr)); 60 fd = ngx_bpf(BPF_PROG_LOAD, &attr, sizeof(attr));
104 union bpf_attr attr; 104 union bpf_attr attr;
105 105
106 ngx_memzero(&attr, sizeof(union bpf_attr)); 106 ngx_memzero(&attr, sizeof(union bpf_attr));
107 107
108 attr.map_fd = fd; 108 attr.map_fd = fd;
109 attr.key = (uint64_t) key; 109 attr.key = (uintptr_t) key;
110 attr.value = (uint64_t) value; 110 attr.value = (uintptr_t) value;
111 attr.flags = flags; 111 attr.flags = flags;
112 112
113 return ngx_bpf(BPF_MAP_UPDATE_ELEM, &attr, sizeof(attr)); 113 return ngx_bpf(BPF_MAP_UPDATE_ELEM, &attr, sizeof(attr));
114 } 114 }
115 115
120 union bpf_attr attr; 120 union bpf_attr attr;
121 121
122 ngx_memzero(&attr, sizeof(union bpf_attr)); 122 ngx_memzero(&attr, sizeof(union bpf_attr));
123 123
124 attr.map_fd = fd; 124 attr.map_fd = fd;
125 attr.key = (uint64_t) key; 125 attr.key = (uintptr_t) key;
126 126
127 return ngx_bpf(BPF_MAP_DELETE_ELEM, &attr, sizeof(attr)); 127 return ngx_bpf(BPF_MAP_DELETE_ELEM, &attr, sizeof(attr));
128 } 128 }
129 129
130 130
134 union bpf_attr attr; 134 union bpf_attr attr;
135 135
136 ngx_memzero(&attr, sizeof(union bpf_attr)); 136 ngx_memzero(&attr, sizeof(union bpf_attr));
137 137
138 attr.map_fd = fd; 138 attr.map_fd = fd;
139 attr.key = (uint64_t) key; 139 attr.key = (uintptr_t) key;
140 attr.value = (uint64_t) value; 140 attr.value = (uintptr_t) value;
141 141
142 return ngx_bpf(BPF_MAP_LOOKUP_ELEM, &attr, sizeof(attr)); 142 return ngx_bpf(BPF_MAP_LOOKUP_ELEM, &attr, sizeof(attr));
143 } 143 }