ip_output( ) 에 대한 질문 인데요 ~

hyper9의 이미지

Kernel Version은 2.6.24 이고요,,

net/ipv4 아래에 있는 ip_output.c에 정의 되어 있는 ip_output( )에 대해
보고 있는데요.

아직은 파악을 제대로 못하고 있습니다.
첫번째로 궁금한 것이, 이 ip_output( )을 부르는 곳이 어디일까 하는 건데요.

이름으로 보면 ip_outpute은 ip 보다 상위 (tcp/udp 같은 곳에서)불러서 traffic을
밖으로 보낼 때 쓸 것 같은데요..

혹시 정확한 위치를 알려주실 수 있나해서 질문 드렸고요.
아니면 참고할만한 자료를 알려주시면 그또한 감사드리겠습니다.

에고,,모르는게 많아서 고생이네요 ~
그럼 조언 부탁 드립니다...

ses1430의 이미지

저도 이번에 숙제하면서 알게 된 사실이긴 합니다만...
udp의 경우 ip_push_pending_frames() 함수에서 ip_output() 함수가 호출됩니다.
함수 아래 부분에 보면 NF_HOOK 매크로 안에서 dst_output() 이라는 함수를 호출합니다.

static inline int dst_output(struct sk_buff *skb)
{
	return skb->dst->output(skb);
}

그리고 __mkroute_output() 함수를 보시면

	rth->rt_spec_dst= fl->fl4_src;
 
	rth->u.dst.output=ip_output;
 
	RT_CACHE_STAT_INC(out_slow_tot);

이러한 형태로 ip_output()의 함수 포인터를 구조체 변수에 할당하고 있습니다.
tcp의 경우는 워낙 자료가 많아서 검색 조금만 하면 금방 나올듯...아마 비슷할 겁니다.

저도 이번 숙제하면서 source insight라는 프로그램을 처음 써봤는데...대단히 편리하더군요...
한번 사용해보시는 것도 좋을것 같네요.

hyper9의 이미지

좀더 공부해보면서 더 궁금한게 생기면 질문도 올리고 그럴게요..
다시 한번 감사드립니다. ^^

hyper9의 이미지


여기저기 아직 공부중인데요 ...

다시 질문이 (좀 수준이 낮은..ㅜㅜ) 생겼습니다..

packet이 ip_rcv() 을 통해서 Linux로 들어오는 것 같은데요.
그리고 ip_forward()를 통해서 ip_output()이런 순으로 바깥으로 전송되는 것 같은데요.

ip_forward()는 어디서 호출이 되는 걸까요?
보고 있지만, 아직 잘 못찾아서 질문 다시 드렸습니다.
미리 감사합니다. ^^

hyper9의 이미지


ip_forward 는 ip_rcv_finish에서 불려진다고 하는 것 같은데요 ..
정확한 point를 아직도 못찾고 있습니다.
혹시 조언 주실 수 있는 분 계시면 감사하겠습니다..

Web에서 찾은 내용은 아래와 같은 게 있었습니다..^^

20.1.2. ip_forward Function

As we have seen, ip_forward is invoked by ip_rcv_finish (see Figure 18-1 in Chapter 18) to handle all input packets that are not addressed to the local system. The function receives as an input parameter the buffer skb associated with the packet; all the necessary information is inside that structure. skb->dst, the routing information, was initialized by the call to ip_route_input in ip_rcv_finish earlier in the code path (see Chapter 33 for more details).

ses1430의 이미지

ip_rcv_finish() 함수의 정의를 보시면 됩니다.
마지막 부분을 보시면

	int err;
 
	for (;;) {
		err = skb->dst->input(skb);

skb->dst->input() 함수를 호출하는데, 첫번째 질문에 대한 답변때와 마찬가지로,
routing table을 탐색하는 과정에서 이 값은 ip_forward 또는 ip_local_deliver 함수의 포인터값으로 채워집니다.

들어온 packet이 local에서 받아야 할 녀석이라면 ip_local_deliver를 할당하고 내보내야(포워딩해야)할 녀석이면 ip_forward를 할당하는 방식이죠.

route.c 파일에 정의된 __mkroute_input 함수의 정의부를 살펴보시면 해당 내용을 찾으실 수 있을 겁니다.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.