LCOV - code coverage report
Current view: top level - net/ipv4 - xfrm4_state.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 40 0.0 %
Date: 2014-04-07 Functions: 0 5 0.0 %
Branches: 0 6 0.0 %

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * xfrm4_state.c
       3                 :            :  *
       4                 :            :  * Changes:
       5                 :            :  *      YOSHIFUJI Hideaki @USAGI
       6                 :            :  *              Split up af-specific portion
       7                 :            :  *
       8                 :            :  */
       9                 :            : 
      10                 :            : #include <net/ip.h>
      11                 :            : #include <net/xfrm.h>
      12                 :            : #include <linux/pfkeyv2.h>
      13                 :            : #include <linux/ipsec.h>
      14                 :            : #include <linux/netfilter_ipv4.h>
      15                 :            : #include <linux/export.h>
      16                 :            : 
      17                 :          0 : static int xfrm4_init_flags(struct xfrm_state *x)
      18                 :            : {
      19         [ #  # ]:          0 :         if (ipv4_config.no_pmtu_disc)
      20                 :          0 :                 x->props.flags |= XFRM_STATE_NOPMTUDISC;
      21                 :          0 :         return 0;
      22                 :            : }
      23                 :            : 
      24                 :            : static void
      25                 :          0 : __xfrm4_init_tempsel(struct xfrm_selector *sel, const struct flowi *fl)
      26                 :            : {
      27                 :            :         const struct flowi4 *fl4 = &fl->u.ip4;
      28                 :            : 
      29                 :          0 :         sel->daddr.a4 = fl4->daddr;
      30                 :          0 :         sel->saddr.a4 = fl4->saddr;
      31                 :          0 :         sel->dport = xfrm_flowi_dport(fl, &fl4->uli);
      32                 :          0 :         sel->dport_mask = htons(0xffff);
      33                 :          0 :         sel->sport = xfrm_flowi_sport(fl, &fl4->uli);
      34                 :          0 :         sel->sport_mask = htons(0xffff);
      35                 :          0 :         sel->family = AF_INET;
      36                 :          0 :         sel->prefixlen_d = 32;
      37                 :          0 :         sel->prefixlen_s = 32;
      38                 :          0 :         sel->proto = fl4->flowi4_proto;
      39                 :          0 :         sel->ifindex = fl4->flowi4_oif;
      40                 :          0 : }
      41                 :            : 
      42                 :            : static void
      43                 :          0 : xfrm4_init_temprop(struct xfrm_state *x, const struct xfrm_tmpl *tmpl,
      44                 :            :                    const xfrm_address_t *daddr, const xfrm_address_t *saddr)
      45                 :            : {
      46                 :          0 :         x->id = tmpl->id;
      47         [ #  # ]:          0 :         if (x->id.daddr.a4 == 0)
      48                 :          0 :                 x->id.daddr.a4 = daddr->a4;
      49                 :          0 :         x->props.saddr = tmpl->saddr;
      50         [ #  # ]:          0 :         if (x->props.saddr.a4 == 0)
      51                 :          0 :                 x->props.saddr.a4 = saddr->a4;
      52                 :          0 :         x->props.mode = tmpl->mode;
      53                 :          0 :         x->props.reqid = tmpl->reqid;
      54                 :          0 :         x->props.family = AF_INET;
      55                 :          0 : }
      56                 :            : 
      57                 :          0 : int xfrm4_extract_header(struct sk_buff *skb)
      58                 :            : {
      59                 :            :         const struct iphdr *iph = ip_hdr(skb);
      60                 :            : 
      61                 :          0 :         XFRM_MODE_SKB_CB(skb)->ihl = sizeof(*iph);
      62                 :          0 :         XFRM_MODE_SKB_CB(skb)->id = iph->id;
      63                 :          0 :         XFRM_MODE_SKB_CB(skb)->frag_off = iph->frag_off;
      64                 :          0 :         XFRM_MODE_SKB_CB(skb)->tos = iph->tos;
      65                 :          0 :         XFRM_MODE_SKB_CB(skb)->ttl = iph->ttl;
      66                 :          0 :         XFRM_MODE_SKB_CB(skb)->optlen = iph->ihl * 4 - sizeof(*iph);
      67                 :          0 :         memset(XFRM_MODE_SKB_CB(skb)->flow_lbl, 0,
      68                 :            :                sizeof(XFRM_MODE_SKB_CB(skb)->flow_lbl));
      69                 :            : 
      70                 :          0 :         return 0;
      71                 :            : }
      72                 :            : 
      73                 :            : static struct xfrm_state_afinfo xfrm4_state_afinfo = {
      74                 :            :         .family                 = AF_INET,
      75                 :            :         .proto                  = IPPROTO_IPIP,
      76                 :            :         .eth_proto              = htons(ETH_P_IP),
      77                 :            :         .owner                  = THIS_MODULE,
      78                 :            :         .init_flags             = xfrm4_init_flags,
      79                 :            :         .init_tempsel           = __xfrm4_init_tempsel,
      80                 :            :         .init_temprop           = xfrm4_init_temprop,
      81                 :            :         .output                 = xfrm4_output,
      82                 :            :         .output_finish          = xfrm4_output_finish,
      83                 :            :         .extract_input          = xfrm4_extract_input,
      84                 :            :         .extract_output         = xfrm4_extract_output,
      85                 :            :         .transport_finish       = xfrm4_transport_finish,
      86                 :            :         .local_error            = xfrm4_local_error,
      87                 :            : };
      88                 :            : 
      89                 :          0 : void __init xfrm4_state_init(void)
      90                 :            : {
      91                 :          0 :         xfrm_state_register_afinfo(&xfrm4_state_afinfo);
      92                 :          0 : }
      93                 :            : 
      94                 :            : #if 0
      95                 :            : void __exit xfrm4_state_fini(void)
      96                 :            : {
      97                 :            :         xfrm_state_unregister_afinfo(&xfrm4_state_afinfo);
      98                 :            : }
      99                 :            : #endif  /*  0  */
     100                 :            : 

Generated by: LCOV version 1.9