aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/core/filter.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/net/core/filter.c b/net/core/filter.c
index 78d00933dbe7..5afe3ac191ec 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -514,14 +514,27 @@ do_pass:
514 break; 514 break;
515 } 515 }
516 516
517 /* Convert JEQ into JNE when 'jump_true' is next insn. */ 517 /* Convert some jumps when 'jump_true' is next insn. */
518 if (fp->jt == 0 && BPF_OP(fp->code) == BPF_JEQ) { 518 if (fp->jt == 0) {
519 insn->code = BPF_JMP | BPF_JNE | bpf_src; 519 switch (BPF_OP(fp->code)) {
520 case BPF_JEQ:
521 insn->code = BPF_JMP | BPF_JNE | bpf_src;
522 break;
523 case BPF_JGT:
524 insn->code = BPF_JMP | BPF_JLE | bpf_src;
525 break;
526 case BPF_JGE:
527 insn->code = BPF_JMP | BPF_JLT | bpf_src;
528 break;
529 default:
530 goto jmp_rest;
531 }
532
520 target = i + fp->jf + 1; 533 target = i + fp->jf + 1;
521 BPF_EMIT_JMP; 534 BPF_EMIT_JMP;
522 break; 535 break;
523 } 536 }
524 537jmp_rest:
525 /* Other jumps are mapped into two insns: Jxx and JA. */ 538 /* Other jumps are mapped into two insns: Jxx and JA. */
526 target = i + fp->jt + 1; 539 target = i + fp->jt + 1;
527 insn->code = BPF_JMP | BPF_OP(fp->code) | bpf_src; 540 insn->code = BPF_JMP | BPF_OP(fp->code) | bpf_src;