@@ -422,26 +422,23 @@ int create_and_get_cgroup(const char *relative_path)
422422}
423423
424424/**
425- * get_cgroup_id() - Get cgroup id for a particular cgroup path
426- * @relative_path : The cgroup path, relative to the workdir, to join
425+ * get_cgroup_id_from_path - Get cgroup id for a particular cgroup path
426+ * @cgroup_workdir : The absolute cgroup path
427427 *
428428 * On success, it returns the cgroup id. On failure it returns 0,
429429 * which is an invalid cgroup id.
430430 * If there is a failure, it prints the error to stderr.
431431 */
432- unsigned long long get_cgroup_id (const char * relative_path )
432+ unsigned long long get_cgroup_id_from_path (const char * cgroup_workdir )
433433{
434434 int dirfd , err , flags , mount_id , fhsize ;
435435 union {
436436 unsigned long long cgid ;
437437 unsigned char raw_bytes [8 ];
438438 } id ;
439- char cgroup_workdir [PATH_MAX + 1 ];
440439 struct file_handle * fhp , * fhp2 ;
441440 unsigned long long ret = 0 ;
442441
443- format_cgroup_path (cgroup_workdir , relative_path );
444-
445442 dirfd = AT_FDCWD ;
446443 flags = 0 ;
447444 fhsize = sizeof (* fhp );
@@ -477,6 +474,14 @@ unsigned long long get_cgroup_id(const char *relative_path)
477474 return ret ;
478475}
479476
477+ unsigned long long get_cgroup_id (const char * relative_path )
478+ {
479+ char cgroup_workdir [PATH_MAX + 1 ];
480+
481+ format_cgroup_path (cgroup_workdir , relative_path );
482+ return get_cgroup_id_from_path (cgroup_workdir );
483+ }
484+
480485int cgroup_setup_and_join (const char * path ) {
481486 int cg_fd ;
482487
@@ -621,3 +626,14 @@ void cleanup_classid_environment(void)
621626 join_cgroup_from_top (NETCLS_MOUNT_PATH );
622627 nftw (cgroup_workdir , nftwfunc , WALK_FD_LIMIT , FTW_DEPTH | FTW_MOUNT );
623628}
629+
630+ /**
631+ * get_classid_cgroup_id - Get the cgroup id of a net_cls cgroup
632+ */
633+ unsigned long long get_classid_cgroup_id (void )
634+ {
635+ char cgroup_workdir [PATH_MAX + 1 ];
636+
637+ format_classid_path (cgroup_workdir );
638+ return get_cgroup_id_from_path (cgroup_workdir );
639+ }
0 commit comments