在Linux的net / ipv4 / udp.c中,为什么需要xfrm4_policy_check()处理UDP数据包?

时间:2011-10-28 17:36:48

标签: c linux-kernel

int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) {
    struct udp_sock *up = udp_sk(sk);
    int rc;
    int is_udplite = IS_UDPLITE(sk);

    /*
     * Charge it to the socket, dropping if the queue is full.
     */
    if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb))
        goto drop;

    nf_reset(skb);

我正在阅读Linux net / ipv4 / udp.c中的代码。任何人都可以向我解释为什么UDP数据包需要通过xfrm_policy_check()运行?

据我所知,函数返回:

  • true :非IPsec数据包/有效IPsec数据包
  • false :无效的IPsec数据包

我可能误解了函数返回值,因为不完全理解源代码。

1 个答案:

答案 0 :(得分:0)

xfrm4_policy_check函数根据IPsec策略检查数据包。如果允许处理数据包,则此函数的返回值为1;如果不允许,则返回零。例如,如果skb->ip_summed未设置为CHECKSUM_UNNECESSASRY且数据包未通过校验和,则IPsec可能决定丢弃数据包。