Skip to content

Commit 9726a7c

Browse files
committed
tlshd: Add init/shutdown hooks for the session tagging subsystem
TLS session tags will be managed in functions contained in a new source file, tags.c. Signed-off-by: Chuck Lever <[email protected]>
1 parent a8704a8 commit 9726a7c

File tree

4 files changed

+61
-3
lines changed

4 files changed

+61
-3
lines changed

src/tlshd/Makefile.am

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ sbin_PROGRAMS = tlshd
2020
tlshd_CFLAGS = -Werror -Wall -Wextra $(LIBGNUTLS_CFLAGS) \
2121
$(LIBKEYUTILS_CFLAGS) $(GLIB_CFLAGS) $(LIBNL3_CFLAGS) \
2222
$(LIBNL_GENL3_CFLAGS) $(LIBYAML_CFLAGS)
23-
tlshd_SOURCES = client.c config.c handshake.c keyring.c ktls.c log.c \
24-
main.c netlink.c netlink.h server.c tlshd.h quic.c
23+
tlshd_SOURCES = client.c config.c handshake.c keyring.c ktls.c \
24+
log.c main.c netlink.c netlink.h quic.c server.c \
25+
tags.c tlshd.h
2526
tlshd_LDADD = $(LIBGNUTLS_LIBS) $(LIBKEYUTILS_LIBS) $(GLIB_LIBS) \
2627
$(LIBNL3_LIBS) $(LIBNL_GENL3_LIBS) $(LIBYAML_LIBS)
2728

src/tlshd/config.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,13 @@ bool tlshd_config_init(const gchar *pathname, bool legacy)
108108
tlshd_keyring_link_session(".nfs");
109109
tlshd_keyring_link_session(".nfsd");
110110

111-
return true;
111+
/* Eventually the tags directory might become a tlshd config option */
112+
return tlshd_tags_config_init("/etc/tlshd/tags.d");
112113
}
113114

114115
void tlshd_config_shutdown(void)
115116
{
117+
tlshd_tags_config_shutdown();
116118
g_key_file_free(tlshd_configuration);
117119
}
118120

src/tlshd/tags.c

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* TLS session tagging
3+
*
4+
* Copyright (c) 2025 Oracle and/or its affiliates.
5+
*
6+
* ktls-utils is free software; you can redistribute it and/or
7+
* modify it under the terms of the GNU General Public License as
8+
* published by the Free Software Foundation; version 2.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
* General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program; if not, write to the Free Software
17+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18+
* 02110-1301, USA.
19+
*/
20+
21+
#include "config.h"
22+
23+
#include <stdbool.h>
24+
#include <keyutils.h>
25+
26+
#include <gnutls/gnutls.h>
27+
#include <gnutls/abstract.h>
28+
29+
#include <glib.h>
30+
31+
#include "tlshd.h"
32+
33+
/* --- Subsystem start-up / shutdown APIs --- */
34+
35+
/**
36+
* tlshd_tags_config_init - Initialize the TLS session tags configuration
37+
* @tagsdir: pathname of directory containing files that define tags
38+
*
39+
*/
40+
bool tlshd_tags_config_init(__attribute__ ((unused)) const char *tagsdir)
41+
{
42+
return true;
43+
}
44+
45+
/**
46+
* tlshd_tags_config_shutdown - Release all tag-related resources
47+
*
48+
*/
49+
void tlshd_tags_config_shutdown(void)
50+
{
51+
}

src/tlshd/tlshd.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ extern void tlshd_genl_done(struct tlshd_handshake_parms *parms);
119119
extern void tlshd_tls13_serverhello_handshake(struct tlshd_handshake_parms *parms);
120120
extern void tlshd_quic_serverhello_handshake(struct tlshd_handshake_parms *parms);
121121

122+
/* tags.c */
123+
extern bool tlshd_tags_config_init(const char *tagsdir);
124+
extern void tlshd_tags_config_shutdown(void);
125+
122126
#ifdef HAVE_GNUTLS_QUIC
123127
#include <linux/quic.h>
124128

0 commit comments

Comments
 (0)