kernel-netlink: Update hardware offload attribute when SAs are updated
This commit is contained in:
@@ -1950,7 +1950,7 @@ METHOD(kernel_ipsec_t, update_sa, status_t,
|
|||||||
size_t len;
|
size_t len;
|
||||||
struct rtattr *rta;
|
struct rtattr *rta;
|
||||||
size_t rtasize;
|
size_t rtasize;
|
||||||
struct xfrm_encap_tmpl* tmpl = NULL;
|
struct xfrm_encap_tmpl* encap = NULL;
|
||||||
struct xfrm_replay_state *replay = NULL;
|
struct xfrm_replay_state *replay = NULL;
|
||||||
struct xfrm_replay_state_esn *replay_esn = NULL;
|
struct xfrm_replay_state_esn *replay_esn = NULL;
|
||||||
struct xfrm_lifetime_cur *lifetime = NULL;
|
struct xfrm_lifetime_cur *lifetime = NULL;
|
||||||
@@ -2075,9 +2075,34 @@ METHOD(kernel_ipsec_t, update_sa, status_t,
|
|||||||
{
|
{
|
||||||
if (rta->rta_type == XFRMA_ENCAP)
|
if (rta->rta_type == XFRMA_ENCAP)
|
||||||
{ /* update encap tmpl */
|
{ /* update encap tmpl */
|
||||||
tmpl = RTA_DATA(rta);
|
encap = RTA_DATA(rta);
|
||||||
tmpl->encap_sport = ntohs(data->new_src->get_port(data->new_src));
|
encap->encap_sport = ntohs(data->new_src->get_port(data->new_src));
|
||||||
tmpl->encap_dport = ntohs(data->new_dst->get_port(data->new_dst));
|
encap->encap_dport = ntohs(data->new_dst->get_port(data->new_dst));
|
||||||
|
}
|
||||||
|
if (rta->rta_type == XFRMA_OFFLOAD_DEV)
|
||||||
|
{ /* update offload device */
|
||||||
|
struct xfrm_user_offload *offload;
|
||||||
|
host_t *local;
|
||||||
|
char *ifname;
|
||||||
|
|
||||||
|
offload = RTA_DATA(rta);
|
||||||
|
local = offload->flags & XFRM_OFFLOAD_INBOUND ? data->new_dst
|
||||||
|
: data->new_src;
|
||||||
|
|
||||||
|
if (charon->kernel->get_interface(charon->kernel, local,
|
||||||
|
&ifname))
|
||||||
|
{
|
||||||
|
offload->ifindex = if_nametoindex(ifname);
|
||||||
|
if (local->get_family(local) == AF_INET6)
|
||||||
|
{
|
||||||
|
offload->flags |= XFRM_OFFLOAD_IPV6;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
offload->flags &= ~XFRM_OFFLOAD_IPV6;
|
||||||
|
}
|
||||||
|
free(ifname);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
netlink_add_attribute(hdr, rta->rta_type,
|
netlink_add_attribute(hdr, rta->rta_type,
|
||||||
chunk_create(RTA_DATA(rta), RTA_PAYLOAD(rta)),
|
chunk_create(RTA_DATA(rta), RTA_PAYLOAD(rta)),
|
||||||
@@ -2086,17 +2111,18 @@ METHOD(kernel_ipsec_t, update_sa, status_t,
|
|||||||
rta = RTA_NEXT(rta, rtasize);
|
rta = RTA_NEXT(rta, rtasize);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tmpl == NULL && data->new_encap)
|
if (encap == NULL && data->new_encap)
|
||||||
{ /* add tmpl if we are enabling it */
|
{ /* add tmpl if we are enabling it */
|
||||||
tmpl = netlink_reserve(hdr, sizeof(request), XFRMA_ENCAP, sizeof(*tmpl));
|
encap = netlink_reserve(hdr, sizeof(request), XFRMA_ENCAP,
|
||||||
if (!tmpl)
|
sizeof(*encap));
|
||||||
|
if (!encap)
|
||||||
{
|
{
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
tmpl->encap_type = UDP_ENCAP_ESPINUDP;
|
encap->encap_type = UDP_ENCAP_ESPINUDP;
|
||||||
tmpl->encap_sport = ntohs(data->new_src->get_port(data->new_src));
|
encap->encap_sport = ntohs(data->new_src->get_port(data->new_src));
|
||||||
tmpl->encap_dport = ntohs(data->new_dst->get_port(data->new_dst));
|
encap->encap_dport = ntohs(data->new_dst->get_port(data->new_dst));
|
||||||
memset(&tmpl->encap_oa, 0, sizeof (xfrm_address_t));
|
memset(&encap->encap_oa, 0, sizeof (xfrm_address_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (replay_esn)
|
if (replay_esn)
|
||||||
|
|||||||
Reference in New Issue
Block a user