func (pl *ProfileLoader) SwapProfileMappings(profile *ProfileMetadata, container *ContainerMetadata) error {
	// 1) Fetch old binary_ids. Any binding between a process and those cookies will need to be updated to
	// the cookies of the new profile.
	oldBinaryIDs, binaryPaths, err := pl.computeListOfBinaryIDs(container.Netns)
	if err != nil {
		return err
	}
	// 2) swap netns / pidns -> profile_id
	nsKeys, err := profile.Profile.Spec.GetProfileNSKeyValues(container.Netns, container.Pidns)
	if err != nil {
		return err
	}
	for _, kv := range nsKeys {
		if err := pl.PutKeyValue(kv); err != nil {
			return err
		}
	}
	// 3) (swap any pid -> binary_id => loop until nothing changes)
	if len(oldBinaryIDs) > 0 {
		if err := pl.swapPidBinaryID(oldBinaryIDs, binaryPaths, profile.Profile); err != nil {
			return err
		}
	}
	return nil
}
// SwapProfileMappings - Ensures that the mappings between the profile and the container in kernel are correct.
Ensures that the mappings between the profile and the container in kernel are correct.
// SwapProfileMappings - Ensures that the mappings between the profile and the container in kernel are correct .
func (pl *ProfileLoader) SwapProfileMappings(profile *ProfileMetadata, container *ContainerMetadata) error {
	oldBinaryIDs, binaryPaths, err := pl.computeListOfBinaryIDs(container.Netns)
	if err != nil {
		return err
	}
	nsKeys, err := profile.Profile.Spec.GetProfileNSKeyValues(container.Netns, container.Pidns)
	if err != nil {
		return err
	}
	for _, kv := range nsKeys {
		if err := pl.PutKeyValue(kv); err != nil {
			return err
		}
	}
	if len(oldBinaryIDs) > 0 {
		if err := pl.swapPidBinaryID(oldBinaryIDs, binaryPaths, profile.Profile); err != nil {
			return err
		}
	}
	return nil
}
func ( pl * ProfileLoader ) SwapProfileMappings ( profile * ProfileMetadata , container * ContainerMetadata ) error { oldBinaryIDs , binaryPaths , err := pl . computeListOfBinaryIDs ( container . Netns ) if err != nil { return err } nsKeys , err := profile . Profile . Spec . GetProfileNSKeyValues ( container . Netns , container . Pidns ) if err != nil { return err } for _ , kv := range nsKeys { if err := pl . PutKeyValue ( kv ) ; err != nil { return err } } if len ( oldBinaryIDs ) > 0 { if err := pl . swapPidBinaryID ( oldBinaryIDs , binaryPaths , profile . Profile ) ; err != nil { return err } } return nil }
Ensures that the mappings between the profile and the container in kernel are correct.
Ensures that the mappings between the profile and the container in kernel are correct .
// 1) Fetch old binary_ids. Any binding between a process and those cookies will need to be updated to // the cookies of the new profile. // 2) swap netns / pidns -> profile_id // 3) (swap any pid -> binary_id => loop until nothing changes)