MCPcopy Create free account
hub / github.com/F-Stack/f-stack / check_syntax

Function check_syntax

dpdk/lib/bpf/bpf_validate.c:1749–1780  ·  view source on GitHub ↗

* make sure that instruction syntax is valid, * and its fields don't violate particular instruction type restrictions. */

Source from the content-addressed store, hash-verified

1747 * and its fields don't violate particular instruction type restrictions.
1748 */
1749static const char *
1750check_syntax(const struct ebpf_insn *ins)
1751{
1752
1753 uint8_t op;
1754 uint16_t off;
1755 uint32_t imm;
1756
1757 op = ins->code;
1758
1759 if (ins_chk[op].mask.dreg == 0)
1760 return "invalid opcode";
1761
1762 if ((ins_chk[op].mask.dreg & 1 << ins->dst_reg) == 0)
1763 return "invalid dst-reg field";
1764
1765 if ((ins_chk[op].mask.sreg & 1 << ins->src_reg) == 0)
1766 return "invalid src-reg field";
1767
1768 off = ins->off;
1769 if (ins_chk[op].off.min > off || ins_chk[op].off.max < off)
1770 return "invalid off field";
1771
1772 imm = ins->imm;
1773 if (ins_chk[op].imm.min > imm || ins_chk[op].imm.max < imm)
1774 return "invalid imm field";
1775
1776 if (ins_chk[op].check != NULL)
1777 return ins_chk[op].check(ins);
1778
1779 return NULL;
1780}
1781
1782/*
1783 * helper function, return instruction index for the given node.

Callers 1

validateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected