Skip to content

Commit 0557a74

Browse files
committed
fix: fix for external domain resolution
1 parent 943ac41 commit 0557a74

3 files changed

Lines changed: 14 additions & 14 deletions

File tree

common/net.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,18 @@ func NewDomain(fqdn string, ips []netaddr.IP) *Domain {
236236
func NewDestinationKey(dst, actualDst netaddr.IPPort, domain *Domain, dstWorkload Workload, actualDestWorkload Workload) DestinationKey {
237237
if IsIpExternal(actualDst.IP()) && domain != nil && !domain.SpecifyIP {
238238
return DestinationKey{
239-
destination: HostPortWithEmptyIP(domain.FQDN, dst.Port()),
239+
destination: HostPortWithEmptyIP(domain.FQDN, dst.Port()),
240+
actualDestination: HostPortFromIPPort(actualDst),
241+
destinationWorkload: Workload{
242+
Kind: "external",
243+
Name: domain.FQDN,
244+
Namespace: "external",
245+
},
246+
actualDestinationWorkload: Workload{
247+
Kind: "external",
248+
Name: actualDst.IP().String(),
249+
Namespace: "external",
250+
},
240251
}
241252
}
242253
return DestinationKey{

containers/container.go

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ func (c *Container) onDNSRequest(r *l7.RequestData) map[netaddr.IP]*common.Domai
763763
return ip2fqdn
764764
}
765765

766-
func (c *Container) onL7Request(pid uint32, fd uint64, timestamp uint64, r *l7.RequestData, iqfqdn map[netaddr.IP]*common.Domain) map[netaddr.IP]*common.Domain {
766+
func (c *Container) onL7Request(pid uint32, fd uint64, timestamp uint64, r *l7.RequestData) map[netaddr.IP]*common.Domain {
767767
c.lock.Lock()
768768
defer c.lock.Unlock()
769769

@@ -778,17 +778,6 @@ func (c *Container) onL7Request(pid uint32, fd uint64, timestamp uint64, r *l7.R
778778
if timestamp != 0 && conn.Timestamp != timestamp {
779779
return nil
780780
}
781-
if conn.dstWorkload.Namespace == "external" && (r.Protocol == l7.ProtocolHTTP || r.Protocol == l7.ProtocolHTTP2) {
782-
if host, ok := iqfqdn[conn.DestinationKey.ActualDestination().IP()]; ok {
783-
log.Printf("Setting external host %s", host)
784-
conn.dstWorkload.Name = host.FQDN
785-
} else {
786-
host, error := l7.ParseHostFromHttpRequest(string(r.Payload))
787-
if error == nil {
788-
conn.dstWorkload.Name = host
789-
}
790-
}
791-
}
792781

793782
// Parse HTTP request once if needed
794783
var req *http.Request

containers/registry.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ func (r *Registry) handleEvents(ch <-chan ebpftracer.Event) {
294294
continue
295295
}
296296
if c := r.containersByPid[e.Pid]; c != nil {
297-
ip2fqdn := c.onL7Request(e.Pid, e.Fd, e.Timestamp, e.L7Request, r.ip2fqdn)
297+
ip2fqdn := c.onL7Request(e.Pid, e.Fd, e.Timestamp, e.L7Request)
298298
r.ip2fqdnLock.Lock()
299299
for ip, domain := range ip2fqdn {
300300
r.ip2fqdn[ip] = domain

0 commit comments

Comments
 (0)