Print this page
WIP to help bringup NAT flows

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/inet/vxlnat_impl.h
          +++ new/usr/src/uts/common/inet/vxlnat_impl.h
↓ open down ↓ 43 lines elided ↑ open up ↑
  44   44  /*
  45   45   * NAT RULES.  Instantiated per-vnet, write-once/read-only entries,
  46   46   * linkage/entries protected by "rule lock" outside this structure.
  47   47   */
  48   48  typedef struct vxlnat_rule_s {
  49   49          list_node_t vxnr_link;
  50   50          /* refheld link, or if NULL, this rule is "condemned" and no good. */
  51   51          struct vxlnat_vnet_s *vxnr_vnet;
  52   52          in6_addr_t vxnr_myaddr;
  53   53          in6_addr_t vxnr_pubaddr;
       54 +        /* XXX KEBE ASKS, ire? */
  54   55          uint8_t vxnr_myether[ETHERADDRL];
  55   56          uint16_t vxnr_vlanid;   /* Fabrics use this too. */
  56   57          uint32_t vxnr_refcount;
  57   58          uint8_t vxnr_prefix;
  58   59  } vxlnat_rule_t;
  59   60  #define VXNR_REFHOLD(vxnr) {                    \
  60   61          atomic_inc_32(&(vxnr)->vxnr_refcount);  \
  61   62          ASSERT((vxnr)->vxnr_refcount > 0);      \
  62   63  }
  63   64  #define VXNR_REFRELE(vxnr) {                                    \
  64   65          ASSERT((vxnr)->vxnr_refcount > 0);                      \
  65   66          membar_exit();                                          \
  66   67          if (atomic_dec_32_nv(&(vxnr)->vxnr_refcount) == 0)      \
  67   68                  vxlnat_rule_free(vxnr);                         \
  68   69  }
  69   70  extern void vxlnat_rule_free(vxlnat_rule_t *);
  70   71  
  71   72  /*
  72   73   * NAT FLOWS.  These are per-vnet, and keyed/searched by:
  73   74   * <inner-IP-source,IP-dest,inner-source-port,dest-port,protocol>.
  74      - * They will be tied-to/part-of
       75 + * They will be tied-to/part-of a conn_t.
  75   76   */
  76   77  typedef struct vxlnat_flow_s {
  77   78          avl_node_t vxnfl_treenode;
  78   79          /*
  79   80           * I'm guessing that dst varies more than src.  Also
  80   81           * the plan is for the comparitor function to bcmp() both
  81   82           * of these as one call for IPv6 (if we ever get to that..).
  82   83           */
  83   84          in6_addr_t vxnfl_dst;
  84   85          in6_addr_t vxnfl_src;   /* INNER source address. */
  85   86          uint32_t vxnfl_ports;
  86   87          uint8_t vxnfl_protocol;
  87   88          uint8_t vxnfl_isv4 : 1, /* Will save us 12 bytes of compares... */
  88   89                  vxlfl_reserved1 : 7;
       90 +        /* Theoretically 16 bits lies where this comment is. */
       91 +        uint32_t vxnfl_refcount;
  89   92          conn_t *vxnfl_connp;    /* Question - embed instead? */
  90   93          vxlnat_rule_t *vxnfl_rule; /* Refhold to rule that generated me. */
       94 +        /*
       95 +         * XXX KEBE SAYS Other NAT-state belongs here too.  Like time-values
       96 +         * for timeouts, and more!
       97 +         */
  91   98  } vxlnat_flow_t;
  92   99  /* Exploit endianisms, maintain network order... */
  93  100  #ifdef _BIG_ENDIAN
  94  101  #define VXNFL_SPORT(ports) (uint16_t)((ports) >> 16) /* Unsigned all around. */
  95  102  #define VXNFL_DPORT(ports) ((ports) & 0xFFFF)
  96  103  #else
  97  104  #define VXNFL_SPORT(ports) ((ports) & 0xFFFF)
  98  105  #define VXNFL_DPORT(ports) (uint16_t)((ports) >> 16) /* Unsigned all around. */
  99  106  #endif
      107 +#define VXNFL_REFHOLD(vxnfl) {                  \
      108 +        atomic_inc_32(&(vxnfl)->vxnfl_refcount);        \
      109 +        ASSERT((vxnfl)->vxnfl_refcount > 0);    \
      110 +}
      111 +#define VXNFL_REFRELE(vxnfl) {                                  \
      112 +        ASSERT((vxnfl)->vxnfl_refcount > 0);                    \
      113 +        membar_exit();                                          \
      114 +        if (atomic_dec_32_nv(&(vxnfl)->vxnfl_refcount) == 0)    \
      115 +                vxlnat_flow_free(vxnfl);                        \
      116 +}
      117 +extern void vxlnat_flow_free(vxlnat_flow_t *);
 100  118  
 101  119  /*
 102  120   * 1-1 IP mapping.
 103  121   */
 104  122  typedef struct vxlnat_fixed_s {
 105  123          avl_node_t vxnf_treenode;
 106  124          in6_addr_t vxnf_addr;   /* For now it needn't match to a rule. */
 107  125          in6_addr_t vxnf_pubaddr; /* External IP. */
 108  126          struct vxlnat_vnet_s *vxnf_vnet;
 109  127          ire_t *vxnf_ire;        /* Should be an IRE_LOCAL from the ftable. */
↓ open down ↓ 146 lines elided ↑ open up ↑
 256  274  /* ire_recvfn & ire_sendfn functions for 1-1/fixed maps. */
 257  275  extern void vxlnat_fixed_ire_recv_v4(ire_t *, mblk_t *, void *,
 258  276      ip_recv_attr_t *);
 259  277  extern void vxlnat_fixed_ire_recv_v6(ire_t *, mblk_t *, void *,
 260  278      ip_recv_attr_t *);
 261  279  extern int vxlnat_fixed_ire_send_v4(ire_t *, mblk_t *, void *,
 262  280      ip_xmit_attr_t *, uint32_t *);
 263  281  extern int vxlnat_fixed_ire_send_v6(ire_t *, mblk_t *, void *,
 264  282      ip_xmit_attr_t *, uint32_t *);
 265  283  
      284 +extern boolean_t vxlnat_new_conn(vxlnat_flow_t *);
      285 +extern void vxlnat_activate_conn(vxlnat_flow_t *);
      286 +#ifdef notyet
      287 +extern void vxlnat_deactivate_conn(vxlnat_flow_t *);
      288 +#endif
 266  289  
 267  290  extern vxlnat_vnet_t *vxlnat_get_vnet(uint32_t, boolean_t);
 268  291  
 269  292  #ifdef __cplusplus
 270  293  }
 271  294  #endif
 272  295  
 273  296  #endif /* _INET_VXLNAT_IMPL_H */
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX