__u16 protocol, __u32 fwmark, __u32 flags);
extern struct ip_vs_dest *ip_vs_try_bind_dest(struct ip_vs_conn *cp);
+static inline void ip_vs_dest_hold(struct ip_vs_dest *dest)
+{
+ atomic_inc(&dest->refcnt);
+}
+
+static inline void ip_vs_dest_put(struct ip_vs_dest *dest)
+{
+ smp_mb__before_atomic_dec();
+ atomic_dec(&dest->refcnt);
+}
/*
* IPVS sync daemon data and function prototypes
return;
/* Increase the refcnt counter of the dest */
- atomic_inc(&dest->refcnt);
+ ip_vs_dest_hold(dest);
conn_flags = atomic_read(&dest->conn_flags);
if (cp->protocol != IPPROTO_UDP)
dest->flags &= ~IP_VS_DEST_F_OVERLOAD;
}
- /*
- * Simply decrease the refcnt of the dest, because the
- * dest will be either in service's destination list
- * or in the trash.
- */
- atomic_dec(&dest->refcnt);
+ ip_vs_dest_put(dest);
}
static int expire_quiescent_template(struct netns_ipvs *ipvs,
if (!dest)
dest = ip_vs_lookup_dest(svc, daddr, port ^ dport);
if (dest)
- atomic_inc(&dest->refcnt);
+ ip_vs_dest_hold(dest);
ip_vs_service_put(svc);
return dest;
}
ntohs(dest->port),
atomic_read(&dest->refcnt));
list_add(&dest->n_list, &ipvs->dest_trash);
- atomic_inc(&dest->refcnt);
+ ip_vs_dest_hold(dest);
}
}
if (!dest) {
dest = ip_vs_try_bind_dest(cp);
if (dest)
- atomic_dec(&dest->refcnt);
+ ip_vs_dest_put(dest);
}
} else {
/*
cp = ip_vs_conn_new(param, daddr, dport, flags, dest, fwmark);
if (dest)
- atomic_dec(&dest->refcnt);
+ ip_vs_dest_put(dest);
if (!cp) {
if (param->pe_data)
kfree(param->pe_data);