Skip to content

Commit 66d28aa

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 7231f21 commit 66d28aa

File tree

4 files changed

+60
-2
lines changed

4 files changed

+60
-2
lines changed

src/tlshd/Makefile.am

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ sbin_PROGRAMS = tlshd
2323
tlshd_CFLAGS = -Werror -Wall -Wextra $(LIBGNUTLS_CFLAGS) \
2424
$(LIBKEYUTILS_CFLAGS) $(GLIB_CFLAGS) $(LIBNL3_CFLAGS) \
2525
$(LIBNL_GENL3_CFLAGS) $(LIBYAML_CFLAGS)
26-
tlshd_SOURCES = client.c config.c handshake.c keyring.c ktls.c log.c \
27-
main.c netlink.c netlink.h server.c tlshd.h quic.c
26+
tlshd_SOURCES = client.c config.c handshake.c keyring.c ktls.c \
27+
log.c main.c netlink.c netlink.h quic.c server.c \
28+
tags.c tlshd.h
2829
tlshd_LDADD = $(LIBGNUTLS_LIBS) $(LIBKEYUTILS_LIBS) $(GLIB_LIBS) \
2930
$(LIBNL3_LIBS) $(LIBNL_GENL3_LIBS) $(LIBYAML_LIBS)
3031

src/tlshd/config.c

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

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

114116
void tlshd_config_shutdown(void)
115117
{
118+
tlshd_tags_config_shutdown();
116119
g_key_file_free(tlshd_configuration);
117120
}
118121

src/tlshd/tags.c

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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+
void tlshd_tags_config_init(__attribute__ ((unused)) const char *tagsdir)
41+
{
42+
}
43+
44+
/**
45+
* tlshd_tags_config_shutdown - Release all tag-related resources
46+
*
47+
*/
48+
void tlshd_tags_config_shutdown(void)
49+
{
50+
}

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 void 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)