IPQ_SET_VERDICT(3)

πŸ’… IPQ_SET_VERDICT β€” the "okay bestie, here's my ruling" page πŸ’…

So this is a page from the Linux Programmer's Manual (section 3, for the library girlies), and it's all about <pink>ipq_set_verdict</pink> β€” the function that lets you pass judgment on a packet. Iconic behavior honestly. πŸ‘‘


✨ NAME ✨

ipq_set_verdict β€” issue a verdict (and optionally a glow-up modified packet) back to the kernel πŸ’Œ


🌸 SYNOPSIS 🌸

#include <linux/netfilter.h>
#include <libipq.h>

int ipq_set_verdict(const struct ipq_handle *h, ipq_id_t id, unsigned int verdict, size_t data_len, unsigned char *buf);

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so picture this: you already grabbed a packet with ipq_read, right? Now ipq_set_verdict is the function where you announce your decision about what should happen to it β€” like the packet's fate is literally in your hands, main character energy fr. And if you want, you can also hand back a modified version of the payload data. Glow-up delivered. ✨

Let me break down the parameters because every single one matters, no skipping:

  • h β€” the context handle 🫢 and here's the thing: it must have previously been returned successfully from a call to ipq_create_handle. No handle, no vibes, no verdict.
  • id β€” the packet identifier, which you got via ipq_get_packet. It's how the kernel knows which packet you're judging. iykyk.
  • verdict β€” the big one, the actual ruling πŸ’… and it must be one of these three:
    • NF_ACCEPT β€” accept the packet and continue traversal within the kernel 🟒 (she's approved, let her through)
    • NF_DROP β€” drop the packet πŸ’€ (blocked, deleted, not today)
    • NF_QUEUE β€” requeue the packet πŸ” (back in line she goes)
  • 🚨 NF_STOLEN and NF_REPEAT are kernel-internal constants and should not be used from userspace β€” like, their exact side effects have not been investigated, so don't be brave. πŸ™ˆ
  • data_len β€” the length of the data pointed to by buf, aka the optional replacement payload data πŸ“¦
  • buf β€” the pointer to that optional replacement payload data.
πŸŽ€ Pro tip straight from the page: if you're simply setting a verdict without modifying the payload data, use zero for data_len and NULL for buf. Easy.

And one more thing bestie, listen: the application is responsible for recalculating any packet checksums when modifying packets. That's on you. Not the kernel. You. 🫡 Do not forget, I'm begging.


πŸ’– RETURN VALUE πŸ’–

  • On failure, -1 is returned 😭
  • On success, a non-zero positive value is returned πŸŽ‰ slay

🌈 ERRORS 🌈

On error, a descriptive error message will be available via the ipq_errstr function. She literally tells you what went wrong. Communication queen. πŸ’…


πŸ’€ BUGS πŸ’€

None known. Flawless. Periodt. πŸ‘‘


🌟 AUTHOR 🌟

James Morris <jmorris@intercode.com.au> β€” thank you king 🫢


Copyright (c) 2000-2001 Netfilter Core Team.

Distributed under the GNU General Public License. πŸ“œ


πŸ”₯ SEE ALSO πŸ”₯

Go read them, they're giving lore. ✨


Okay that's the whole page, mwah πŸ’‹ β€” and just so we're fully cited, this came from Linux iptables 1.2, dated 16 October 2001, in the good old Linux Programmer's Manual. Vintage but still serving. πŸŽ€βœ¨

πŸ“¦ where this page comes from