Skip to Content
BPF로 리눅스 관측 가능성 향상하기: 성능 분석과 네트워킹을 위한 고급 프로그래밍
book

BPF로 리눅스 관측 가능성 향상하기: 성능 분석과 네트워킹을 위한 고급 프로그래밍

by 류광, 데이비드 칼라베라, 로렌초 폰타나
May 2020
Beginner to intermediate
236 pages
5h 15m
Korean
Hanbit Media, Inc.
Content preview from BPF로 리눅스 관측 가능성 향상하기: 성능 분석과 네트워킹을 위한 고급 프로그래밍
3.2 BPF 맵 다루기
55
할 것이다.
이번 장에서 다루는 대부분의 맵 유형은 배열처럼 행동하므로, 이런 식으로 맵을 훑으면 애
초에 맵에 요소들을 저장한 순서와 같은 순서로 요소들을 얻게 된다. 다음으로는 맵의 특정 요
소를 찾아서 삭제하는 연산을 살펴보자.
3.2.5
특정 요소를 찾아서 삭제
커널이 제공하는 맵 관련 보조 함수로 주목할 만한 것이 또 있는데, 바로
bpf
_
map
_
lookup
_
and
_
delete
_
elem
이다. 이 함수는 주어진 키에 해당하는 요소를 찾아서 삭제한다. 또한, 그 요
소의 값을 프로그램의 한 변수에 설정한다. 이 함수는
BPF
맵을 대기열 (
queue
)이나 스택
stack
으로 사용할 때 유용하다. 대기열 맵과 스택 맵은 다음 절들에서 이야기하겠다. 물론 이 함수를
꼭 그런 유형의 맵들에만 사용할 수 있는 것은 아니다. 그럼 이전 예제들에서 사용한 맵에 대해
이 함수를 적용하는 예제를 보자.
int key, value, result, it;
key = 1;
for (it = 0; it < 2; it++) {
result = bpf_map_lookup_and_delete_elem(map_data[0].fd, &key, &value);
if (result == 0)
printf("Value read from the map: '%d'\n", ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

컨테이너 보안: 컨테이너화된 응용 프로그램의 보안을 위한 개념, 이론, 대응법과 모범 관행까지

컨테이너 보안: 컨테이너화된 응용 프로그램의 보안을 위한 개념, 이론, 대응법과 모범 관행까지

류광, 리즈 라이스

Publisher Resources

ISBN: 9791162243053