Lines Matching full:idx
80 /* The bpf_mprog_{replace,delete}() operate on exact idx position with the
82 * case of front idx is -1, in case of back idx is bpf_mprog_total(entry).
86 * idx + before:
88 * Insert P4 before P3: idx for old array is 1, idx for new array is 2,
89 * hence we adjust target idx for the new array, so that memmove copies
90 * P1 and P2 to the new entry, and we insert P4 into idx 2. Inserting
91 * before P1 would have old idx -1 and new idx 0.
97 * idx + after:
99 * Insert P4 after P2: idx for old array is 2, idx for new array is 2.
101 * into idx 2. Inserting after P3 would have both old/new idx at 4 aka
110 struct bpf_tuple *ntuple, int idx) in bpf_mprog_replace() argument
116 bpf_mprog_read(entry, idx, &fp, &cp); in bpf_mprog_replace()
129 struct bpf_tuple *ntuple, int idx, u32 flags) in bpf_mprog_insert() argument
138 if (idx == total) in bpf_mprog_insert()
141 idx += 1; in bpf_mprog_insert()
142 bpf_mprog_entry_grow(peer, idx); in bpf_mprog_insert()
144 bpf_mprog_read(peer, idx, &fp, &cp); in bpf_mprog_insert()
153 struct bpf_tuple *dtuple, int idx) in bpf_mprog_delete() argument
160 if (idx == -1) in bpf_mprog_delete()
161 idx = 0; in bpf_mprog_delete()
162 else if (idx == total) in bpf_mprog_delete()
163 idx = total - 1; in bpf_mprog_delete()
164 bpf_mprog_entry_shrink(peer, idx); in bpf_mprog_delete()
238 int ret, idx = -ERANGE, tidx; in bpf_mprog_attach() local
255 idx = tidx; in bpf_mprog_attach()
262 if (tidx < -1 || (idx >= -1 && tidx != idx)) { in bpf_mprog_attach()
266 idx = tidx; in bpf_mprog_attach()
270 if (tidx < -1 || (idx >= -1 && tidx != idx)) { in bpf_mprog_attach()
274 idx = tidx; in bpf_mprog_attach()
276 if (idx < -1) { in bpf_mprog_attach()
281 idx = bpf_mprog_total(entry); in bpf_mprog_attach()
284 if (idx >= bpf_mprog_max()) { in bpf_mprog_attach()
289 ret = bpf_mprog_replace(entry, entry_new, &ntuple, idx); in bpf_mprog_attach()
291 ret = bpf_mprog_insert(entry, entry_new, &ntuple, idx, flags); in bpf_mprog_attach()
298 struct bpf_tuple *tuple, int idx) in bpf_mprog_fetch() argument
306 if (idx == -1) in bpf_mprog_fetch()
307 idx = 0; in bpf_mprog_fetch()
308 else if (idx == total) in bpf_mprog_fetch()
309 idx = total - 1; in bpf_mprog_fetch()
310 bpf_mprog_read(entry, idx, &fp, &cp); in bpf_mprog_fetch()
314 * case it gets populated here based on idx, or with filled tuple in bpf_mprog_fetch()
337 int ret, idx = -ERANGE, tidx; in bpf_mprog_detach() local
356 idx = tidx; in bpf_mprog_detach()
360 if (tidx < -1 || (idx >= -1 && tidx != idx)) { in bpf_mprog_detach()
364 idx = tidx; in bpf_mprog_detach()
368 if (tidx < -1 || (idx >= -1 && tidx != idx)) { in bpf_mprog_detach()
372 idx = tidx; in bpf_mprog_detach()
374 if (idx < -1) { in bpf_mprog_detach()
379 idx = bpf_mprog_total(entry); in bpf_mprog_detach()
382 if (idx >= bpf_mprog_max()) { in bpf_mprog_detach()
386 ret = bpf_mprog_fetch(entry, &dtuple, idx); in bpf_mprog_detach()
389 ret = bpf_mprog_delete(entry, entry_new, &dtuple, idx); in bpf_mprog_detach()