]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
ike: Set DCSP on keepalive packets
authorAdrian-Ken Rueegsegger <ken@codelabs.ch>
Tue, 9 Mar 2021 17:07:34 +0000 (18:07 +0100)
committerTobias Brunner <tobias@strongswan.org>
Fri, 7 May 2021 12:29:24 +0000 (14:29 +0200)
src/libcharon/sa/ike_sa.c

index bf9966b15d1364afd015930e7e142f7a804be7e3..51a84424935e2f82f92b35952a06eace88adff52 100644 (file)
@@ -638,6 +638,29 @@ METHOD(ike_sa_t, get_message_id, uint32_t,
        return this->task_manager->get_mid(this->task_manager, initiate);
 }
 
+/**
+ * Set configured DSCP value on packet
+ */
+static void set_dscp(private_ike_sa_t *this, packet_t *packet)
+{
+       ike_cfg_t *ike_cfg;
+
+       /* prefer IKE config on peer_cfg, as its selection is more accurate
+        * then the initial IKE config */
+       if (this->peer_cfg)
+       {
+               ike_cfg = this->peer_cfg->get_ike_cfg(this->peer_cfg);
+       }
+       else
+       {
+               ike_cfg = this->ike_cfg;
+       }
+       if (ike_cfg)
+       {
+               packet->set_dscp(packet, ike_cfg->get_dscp(ike_cfg));
+       }
+}
+
 METHOD(ike_sa_t, send_keepalive, void,
        private_ike_sa_t *this, bool scheduled)
 {
@@ -681,6 +704,7 @@ METHOD(ike_sa_t, send_keepalive, void,
                packet = packet_create();
                packet->set_source(packet, this->my_host->clone(this->my_host));
                packet->set_destination(packet, this->other_host->clone(this->other_host));
+               set_dscp(this, packet);
                data.ptr = malloc(1);
                data.ptr[0] = 0xFF;
                data.len = 1;
@@ -1204,29 +1228,6 @@ METHOD(ike_sa_t, update_hosts, void,
        }
 }
 
-/**
- * Set configured DSCP value on packet
- */
-static void set_dscp(private_ike_sa_t *this, packet_t *packet)
-{
-       ike_cfg_t *ike_cfg;
-
-       /* prefer IKE config on peer_cfg, as its selection is more accurate
-        * then the initial IKE config */
-       if (this->peer_cfg)
-       {
-               ike_cfg = this->peer_cfg->get_ike_cfg(this->peer_cfg);
-       }
-       else
-       {
-               ike_cfg = this->ike_cfg;
-       }
-       if (ike_cfg)
-       {
-               packet->set_dscp(packet, ike_cfg->get_dscp(ike_cfg));
-       }
-}
-
 METHOD(ike_sa_t, generate_message, status_t,
        private_ike_sa_t *this, message_t *message, packet_t **packet)
 {